-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.ts
77 lines (70 loc) · 2 KB
/
gatsby-node.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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 {
collection_id
scd_publish_status
record_type
collection_content_category
collection_title
collection_description
collection_holder_category
collection_holder_name
collection_holder_city
collection_holder_state
collection_holder_country
content_types
dates
extent
historical_relevance
subjects
creators
physical_formats
access_statement
finding_aid_url
collection_catalog_url
supporting_documentation
languages
inventory_description
}
}
}
allAirtableScdFields {
nodes {
data {
Fields
scd_field_label_revised
}
}
}
}
`)
const r = results.data as Queries.qCollectionsQuery;
const {nodes} = r.allAirtableScdItems;
const fields = r.allAirtableScdFields.nodes;
for (const node of nodes) {
const collection = node.data
createPage({
path: `/collections/${collection?.collection_id}/`,
component: path.resolve(`./src/templates/collection.tsx`),
context: {
collection: {...collection},
fields
}
})
}
}