11import path from "path" ;
22import type { GatsbyNode } from "gatsby" ;
33import { flattenPages } from "./src/utils/utils" ;
4- import { EventFrontmatter , NewsFrontmatter , PageFrontmatter , StrudelPage , TaskFlowFrontmatter } from "./src/types/strudel-config" ;
4+ import { EventFrontmatter , GalleryFrontmatter , NewsFrontmatter , PageFrontmatter , StrudelPage , TaskFlowFrontmatter } from "./src/types/strudel-config" ;
55
66/**
77 * Shape of the result from the graphql query
@@ -44,6 +44,17 @@ interface Result {
4444 }
4545 } [ ]
4646 }
47+ gallery : {
48+ nodes : {
49+ frontmatter : GalleryFrontmatter ,
50+ internal : {
51+ contentFilePath : string ;
52+ } ,
53+ fields : {
54+ source : string ;
55+ }
56+ } [ ]
57+ }
4758 }
4859}
4960
@@ -159,6 +170,37 @@ export const createPages: GatsbyNode["createPages"] = async ({
159170 }
160171 }
161172 }
173+ gallery: allMdx(filter: {fields: {source: {eq: "gallery"}}}) {
174+ nodes {
175+ fields {
176+ source
177+ }
178+ frontmatter {
179+ title
180+ slug
181+ contributors
182+ appType
183+ repoUrl
184+ liveUrl
185+ primaryImage {
186+ childImageSharp {
187+ gatsbyImageData
188+ }
189+ absolutePath
190+ }
191+ otherImages {
192+ childImageSharp {
193+ gatsbyImageData
194+ }
195+ absolutePath
196+ }
197+ }
198+ excerpt
199+ internal {
200+ contentFilePath
201+ }
202+ }
203+ }
162204 }
163205 `
164206 ) ;
@@ -173,6 +215,7 @@ export const createPages: GatsbyNode["createPages"] = async ({
173215 const mdxPages = result . data ?. content . nodes ;
174216 const eventPages = result . data ?. events . nodes ;
175217 const newsPages = result . data ?. news . nodes ;
218+ const galleryPages = result . data ?. gallery . nodes ;
176219
177220 /**
178221 * Create a page for each page object that has an associated markdown file.
@@ -243,6 +286,22 @@ export const createPages: GatsbyNode["createPages"] = async ({
243286 } )
244287 }
245288
289+ /**
290+ * Create a page for each gallery mdx node.
291+ */
292+ if ( galleryPages ) {
293+ const galleryTemplate = path . resolve ( `src/components/layouts/GalleryDetailLayout.tsx` )
294+ galleryPages . forEach ( ( galleryPage ) => {
295+ createPage ( {
296+ path : `/gallery/${ galleryPage . frontmatter . slug } ` ,
297+ component : `${ galleryTemplate } ?__contentFilePath=${ galleryPage . internal . contentFilePath } ` ,
298+ context : {
299+ frontmatter : galleryPage . frontmatter ,
300+ }
301+ } ) ;
302+ } )
303+ }
304+
246305 /**
247306 * Add redirects for top-level routes that
248307 * don't have specific pages associated with them.
0 commit comments