From 165a671781f1365487a95bba63ecdc81e8560c62 Mon Sep 17 00:00:00 2001 From: Raff Viglianti Date: Mon, 28 Oct 2024 15:59:38 -0400 Subject: [PATCH] pages for collections --- gatsby-node.ts | 61 +++++++++++++++++++++++++++++++++++++++ src/components/Footer.tsx | 2 +- src/components/Layout.tsx | 6 ++-- src/styles/global.css | 2 +- 4 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 gatsby-node.ts diff --git a/gatsby-node.ts b/gatsby-node.ts new file mode 100644 index 000000000..3a6ff5421 --- /dev/null +++ b/gatsby-node.ts @@ -0,0 +1,61 @@ +import type { Actions, CreatePagesArgs, GatsbyNode } from "gatsby"; +import path from "path"; + +interface IMakePages { + createPage: Actions["createPage"] + graphql: CreatePagesArgs["graphql"] +} + +export const createPages: GatsbyNode["createPages"] = async ({ actions: { createPage }, graphql }) => { + + const utils: IMakePages = {createPage, graphql}; + + await makeCollectionPages(utils) +} + +async function makeCollectionPages({createPage, graphql}: IMakePages) { + const results = await graphql(` + query qCollections { + allAirtableScdItems( + filter: {data: {scd_publish_status: {nin: ["duplicate-record-do-not-display", "do-not-display"]}}} + ) { + nodes { + data { + _xxxid + scd_publish_status + _xxxcollectionOwnerNamextxt + _xxxcollectionTitlextxt + _xxxcollectionDescriptionxtxt + _xxxcollectionExtentxtxt + _xcollectionFormatsxtxtxxxcollectionFormatsxtxt + _xxxcollectionContentTypesxtxtxxxcollectionContentTypesxtxt + _xxxcollectionGenresxtxtxxxcollectionGenresxtxt + _xxxcollectionFindingAidUrlxtxt + _xxxcollectionOwnerLocationCountryxtxt + _xxxcollectionOwnerLocationStatextxt + _xxxcollectionCatalogUrlxtxt + _xxxcollectionInventoryDescriptionxtxtxxxcollectionInventoryDescriptionxtxt + _xxxcollectionLanguagesxtxtxxxcollectionLanguagesxtxt + _xxxcollectionNotesxtxt + _xxxcollectionOwnerLocationCityxtxt + _xxxcollectionUsageStatementxtxt + _xxxcollectionWebsiteUrlxtxt + } + } + } + } + `) + + const {nodes} = (results.data as Queries.qCollectionsQuery).allAirtableScdItems; + + for (const node of nodes) { + const collection = node.data + createPage({ + path: `/collections/${collection?._xxxid}/`, + component: path.resolve(`./src/templates/collection.tsx`), + context: { + ...collection + } + }) + } +} diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 3532e7095..4f4c88c55 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -5,7 +5,7 @@ import logoArsc from "../images/arsc-logo.png" import logoMith from "../images/MITHgrayscale.png" const Footer = () => { - return (