diff --git a/gatsby-node.ts b/gatsby-node.ts index 3a6ff5421..dc50cd61e 100644 --- a/gatsby-node.ts +++ b/gatsby-node.ts @@ -21,25 +21,24 @@ async function makeCollectionPages({createPage, graphql}: IMakePages) { ) { nodes { data { - _xxxid + collection_id scd_publish_status - _xxxcollectionOwnerNamextxt - _xxxcollectionTitlextxt - _xxxcollectionDescriptionxtxt - _xxxcollectionExtentxtxt - _xcollectionFormatsxtxtxxxcollectionFormatsxtxt - _xxxcollectionContentTypesxtxtxxxcollectionContentTypesxtxt - _xxxcollectionGenresxtxtxxxcollectionGenresxtxt - _xxxcollectionFindingAidUrlxtxt - _xxxcollectionOwnerLocationCountryxtxt - _xxxcollectionOwnerLocationStatextxt - _xxxcollectionCatalogUrlxtxt - _xxxcollectionInventoryDescriptionxtxtxxxcollectionInventoryDescriptionxtxt - _xxxcollectionLanguagesxtxtxxxcollectionLanguagesxtxt - _xxxcollectionNotesxtxt - _xxxcollectionOwnerLocationCityxtxt - _xxxcollectionUsageStatementxtxt - _xxxcollectionWebsiteUrlxtxt + collection_holder_name + collection_title + collection_description + collection_extent + collectionFormats + content_types + collection_finding_aid_url + collection_holder_country + collection_holder_state + collection_holder_city + collection_catalog_url + inventory_description + languages + collection_notes + collection_usage_statement + collection_website_url } } } @@ -51,7 +50,7 @@ async function makeCollectionPages({createPage, graphql}: IMakePages) { for (const node of nodes) { const collection = node.data createPage({ - path: `/collections/${collection?._xxxid}/`, + path: `/collections/${collection?.collection_id}/`, component: path.resolve(`./src/templates/collection.tsx`), context: { ...collection diff --git a/src/pages/search.tsx b/src/pages/search.tsx index b4b3f7e98..fce432bf5 100644 --- a/src/pages/search.tsx +++ b/src/pages/search.tsx @@ -1,5 +1,6 @@ import * as React from "react" import { graphql, Link, type HeadFC, type PageProps } from "gatsby" +import { FieldsMap } from "../fieldsMap" import Layout from "../components/Layout" import Button from "../components/Button" import Pagination from "../components/Pagination" @@ -18,17 +19,18 @@ const Results = ({results, start}: ResultProps) => (
{results.map((r, i) => { const d = r.data! - const faURL = d._xxxcollectionFindingAidUrlxtxt && d._xxxcollectionFindingAidUrlxtxt.startsWith("http") ? d._xxxcollectionFindingAidUrlxtxt : `http://${d._xxxcollectionFindingAidUrlxtxt}` - const ctypes = d._xxxcollectionContentTypesxtxtxxxcollectionContentTypesxtxt || [] - return
+ d.collection_finding_aid_url + const faURL = d.collection_finding_aid_url && d.collection_finding_aid_url?.startsWith("http") ? d.collection_finding_aid_url : `http://${d.collection_finding_aid_url}` + const ctypes = d.content_types || [] + return

- {start + i}. {d._xxxcollectionTitlextxt} + {start + i}. {d.collection_title}

- {d._xxxcollectionDescriptionxtxt && + {d.collection_description && - + } {d.scd_publish_status !== "collection-owner-title-description-only" && <> {ctypes.length > 0 && @@ -37,22 +39,22 @@ const Results = ({results, start}: ResultProps) => ( } - {d._xcollectionFormatsxtxtxxxcollectionFormatsxtxt && + {d.collectionFormats && - + } - {d._xxxcollectionExtentxtxt && + {d.collection_extent && - + } - {d._xxxcollectionFindingAidUrlxtxt && + {d.collection_finding_aid_url && } } - +
Description:{d._xxxcollectionDescriptionxtxt}{d.collection_description}
{ctypes.join("; ")}
Format:{d._xcollectionFormatsxtxtxxxcollectionFormatsxtxt}{d.collectionFormats}
Extent:{d._xxxcollectionExtentxtxt}{d.collection_extent}
Online finding aid: View on {new URL(faURL).hostname}
Repository/Collector:{d._xxxcollectionOwnerNamextxt}{d.collection_holder_name}
@@ -78,12 +80,11 @@ const SearchPage: React.FC = ({data}) => { const [facets, setFacets] = React.useState([]); const facetFields = new Map([ - ["Content type", "_xxxcollectionContentTypesxtxtxxxcollectionContentTypesxtxt"], - ["Format", "_xcollectionFormatsxtxtxxxcollectionFormatsxtxt"], - ["Genre", "_xxxcollectionGenresxtxtxxxcollectionGenresxtxt"], - ["Repository/Collector", "_xxxcollectionOwnerNamextxt"], - ["Country (Location)", "_xxxcollectionOwnerLocationCountryxtxt"], - ["State (Location)", "_xxxcollectionOwnerLocationStatextxt"] + ["Content type", "content_types"], + ["Format", "collectionFormats"], + ["Repository/Collector", "collection_holder_name"], + ["Country (Location)", "collection_holder_country"], + ["State (Location)", "collection_holder_state"] ]) // apply facets @@ -102,9 +103,9 @@ const SearchPage: React.FC = ({data}) => { // sort then paginate (facetedResults as DeepWritable).sort((a, b) => { if (sortOrder === "asc") { - return a.data!._xxxcollectionTitlextxt!.localeCompare(b.data!._xxxcollectionTitlextxt!) + return a.data!.collection_title!.localeCompare(b.data!.collection_title!) } else { - return b.data!._xxxcollectionTitlextxt!.localeCompare(a.data!._xxxcollectionTitlextxt!) + return b.data!.collection_title!.localeCompare(a.data!.collection_title!) } }) const paginatedResults = facetedResults.slice(startIndex, endIndex) @@ -328,22 +329,21 @@ export const query = graphql` query qSearchPage { allAirtableScdItems( filter: {data: {scd_publish_status: {nin: ["duplicate-record-do-not-display", "do-not-display"]}}} - sort: {data: {_xxxcollectionTitlextxt: ASC}} + sort: {data: {collection_title: ASC}} ) { nodes { data { - _xxxid + collection_id scd_publish_status - _xxxcollectionDescriptionxtxt - _xxxcollectionOwnerNamextxt - _xxxcollectionTitlextxt - _xxxcollectionExtentxtxt - _xcollectionFormatsxtxtxxxcollectionFormatsxtxt - _xxxcollectionContentTypesxtxtxxxcollectionContentTypesxtxt - _xxxcollectionGenresxtxtxxxcollectionGenresxtxt - _xxxcollectionFindingAidUrlxtxt - _xxxcollectionOwnerLocationCountryxtxt - _xxxcollectionOwnerLocationStatextxt + collection_description + collection_holder_name + collection_title + collection_extent + collectionFormats + content_types + collection_finding_aid_url + collection_holder_country + collection_holder_state } } } diff --git a/src/templates/collection.tsx b/src/templates/collection.tsx index 566ecb4c5..f03078a58 100644 --- a/src/templates/collection.tsx +++ b/src/templates/collection.tsx @@ -1,35 +1,34 @@ import * as React from "react" -import { graphql, Link, type HeadFC, type PageProps } from "gatsby" +import { Link, type HeadFC, type PageProps } from "gatsby" import Layout from "../components/Layout" const Collection: React.FC = ({pageContext}) => { const data = pageContext as Queries.qCollectionsQuery["allAirtableScdItems"]["nodes"][0]["data"] const d = data! - const faURL = d._xxxcollectionFindingAidUrlxtxt && d._xxxcollectionFindingAidUrlxtxt.startsWith("http") ? d._xxxcollectionFindingAidUrlxtxt : `http://${d._xxxcollectionFindingAidUrlxtxt}` - const catURL = d._xxxcollectionCatalogUrlxtxt && d._xxxcollectionCatalogUrlxtxt.startsWith("http") ? d._xxxcollectionCatalogUrlxtxt : `http://${d._xxxcollectionCatalogUrlxtxt}` - const webURL = d._xxxcollectionWebsiteUrlxtxt && d._xxxcollectionWebsiteUrlxtxt.startsWith("http") ? d._xxxcollectionWebsiteUrlxtxt : `http://${d._xxxcollectionWebsiteUrlxtxt}` - const ctypes = d._xxxcollectionContentTypesxtxtxxxcollectionContentTypesxtxt || [] - const genres = d._xxxcollectionGenresxtxtxxxcollectionGenresxtxt || [] - const langs = d._xxxcollectionLanguagesxtxtxxxcollectionLanguagesxtxt || [] + const faURL = d.collection_finding_aid_url && d.collection_finding_aid_url.startsWith("http") ? d.collection_finding_aid_url : `http://${d.collection_finding_aid_url}` + const catURL = d.collection_catalog_url && d.collection_catalog_url.startsWith("http") ? d.collection_catalog_url : `http://${d.collection_catalog_url}` + const webURL = d.collection_website_url && d.collection_website_url.startsWith("http") ? d.collection_website_url : `http://${d.collection_website_url}` + const ctypes = d.content_types || [] + const langs = d.languages || [] const loc = [] - d._xxxcollectionOwnerLocationCityxtxt ? loc.push(d._xxxcollectionOwnerLocationCityxtxt) : false; - d._xxxcollectionOwnerLocationStatextxt ? loc.push(d._xxxcollectionOwnerLocationStatextxt) : false; - d._xxxcollectionOwnerLocationCountryxtxt ? loc.push(d._xxxcollectionOwnerLocationCountryxtxt) : false; + d.collection_holder_city ? loc.push(d.collection_holder_city) : false; + d.collection_holder_state ? loc.push(d.collection_holder_state) : false; + d.collection_holder_country ? loc.push(d.collection_holder_country) : false; return (
-
+

- {d._xxxcollectionTitlextxt} + {d.collection_title}

« Back to search

- {d._xxxcollectionDescriptionxtxt && + {d.collection_description && - + } { // additional fields for public entries. d.scd_publish_status !== "collection-owner-title-description-only" && <> @@ -37,19 +36,13 @@ const Collection: React.FC = ({pageContext}) => { - {genres.length > 0 && - - - - - } - {d._xcollectionFormatsxtxtxxxcollectionFormatsxtxt && + {d.collectionFormats && - + } - {d._xxxcollectionExtentxtxt && + {d.collection_extent && - + } {langs.length > 0 && @@ -57,21 +50,21 @@ const Collection: React.FC = ({pageContext}) => { } - {d._xxxcollectionNotesxtxt && + {d.collection_notes && - + } - {d._xxxcollectionFindingAidUrlxtxt && + {d.collection_finding_aid_url && } - {d._xxxcollectionCatalogUrlxtxt && + {d.collection_catalog_url && } - {d._xxxcollectionWebsiteUrlxtxt && + {d.collection_website_url && } @@ -79,7 +72,7 @@ const Collection: React.FC = ({pageContext}) => { } - + { // additional fields for public entries. d.scd_publish_status !== "collection-owner-title-description-only" && <> @@ -87,10 +80,10 @@ const Collection: React.FC = ({pageContext}) => { - {d._xxxcollectionUsageStatementxtxt && + {d.collection_usage_statement && - + } } @@ -105,4 +98,4 @@ const Collection: React.FC = ({pageContext}) => { export default Collection -export const Head: HeadFC = ({pageContext}) => {(pageContext as Queries.qCollectionsQuery["allAirtableScdItems"]["nodes"][0]["data"])?._xxxcollectionTitlextxt} | RPTF/ARSC Sound Collections Database +export const Head: HeadFC = ({pageContext}) => {(pageContext as Queries.qCollectionsQuery["allAirtableScdItems"]["nodes"][0]["data"])?.collection_title} | RPTF/ARSC Sound Collections Database
Description:{d._xxxcollectionDescriptionxtxt}{d.collection_description}
Content type{ctypes.length > 1 ? 's': ''}: {ctypes.join("; ")}
Genre{genres.length > 1 ? 's': ''}:{genres.join("; ")}
Format:{d._xcollectionFormatsxtxtxxxcollectionFormatsxtxt}{d.collectionFormats}
Extent:{d._xxxcollectionExtentxtxt}{d.collection_extent}
{langs.join("; ")}
Additional notes:{d._xxxcollectionNotesxtxt}{d.collection_notes}
Online finding aid: View on {new URL(faURL).hostname}
Online catalog: View on {new URL(catURL).hostname}
Collection website: View on {new URL(webURL).hostname}
Repository/Collector:{d._xxxcollectionOwnerNamextxt}{d.collection_holder_name}
Location: {loc.join(", ")}
Usage statement:{d._xxxcollectionUsageStatementxtxt}{d.collection_usage_statement}