-
Hi Everyone, I'm integrating DSG into pages using a DSG field at Sanity.io. I'm also using the file API routing solution to generate the pages. Sending it through GraphQL is fine and Gatsby is reading it, however getting the GraphQL query noticed in the DSG Config is really tripping me up. How do you either:
Here's a working
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
Hi! You would do a query like this: {
allSanitySiteRoute {
title
slug {
current
}
pageType
}
} And then compare the result of Here's an example but with markdown, the concept is the same: https://www.gatsbyjs.com/docs/how-to/rendering-options/using-deferred-static-generation/#file-system-route-api |
Beta Was this translation helpful? Give feedback.
-
With this it's all working fine: Codeimport React from 'react'
import { graphql } from 'gatsby'
import Layout from "../components/layout"
import Seo from "../components/seo"
const Page = ({ data }) => {
const { title } = data.page
return (
<Layout>
<Seo title="Post" />
<h1>{title}</h1>
</Layout>
)
}
export default Page
export const query = graphql`
query($id: String) {
page: sanitySiteRoute(id: { eq: $id }) {
title
slug {
current
}
pageType
}
}
`
export async function config() {
const { data } = graphql`
{
allSanitySiteRoute(filter: {pageType: {eq: "DSG"}}){
nodes {
pageType
slug {
current
}
}
}
}
`
const dsgPosts = new Set(data.allSanitySiteRoute.nodes.map(node => node.slug.current))
return ({ params }) => {
return {
defer: dsgPosts.has(params.slug__current)
}
}
} The error |
Beta Was this translation helpful? Give feedback.
With this it's all working fine:
Code