I've been racking my brain on this. In Prismic I have Rich Text content with links. I've linked them directly to content but the graphql response comes back with href=""
Here's my setup:
gatsby-config.js
{
resolve: "gatsby-source-prismic",
options: {
repositoryName: process.env.PRISMIC_REPO,
accessToken: process.env.PRISMIC_TOKEN,
schemas: {
page: require("./src/schemas/page.json"),
...
},
linkResolver: linkResolver,
shouldDownloadImage: () => {
return false
},
},
},
linkResolver.js
module.exports = ({ node, key, value }) => doc => {
console.log("doc", doc)
if (doc.type === "page") {
if (doc.uid === "home") {
return "/"
} else {
return `/${doc.uid}`
}
}
return `/${doc.uid}`
}
graphql query:
items {
title {
text
}
content {
html
}
}
render
<div
className="font-light prose prose-sm"
dangerouslySetInnerHTML={{ __html: feature.content.html }}
/>