Skip to content

Commit

Permalink
switched fields names
Browse files Browse the repository at this point in the history
  • Loading branch information
raffazizzi committed Nov 1, 2024
1 parent 8eb3a8e commit 3218132
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 84 deletions.
37 changes: 18 additions & 19 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand All @@ -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
Expand Down
64 changes: 32 additions & 32 deletions src/pages/search.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -18,17 +19,18 @@ const Results = ({results, start}: ResultProps) => (
<section className="px-0 mx-5">
{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 <article className="border-b border-dotted border-slate-300 mb-7 pt-4" key={d._xxxid}>
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 <article className="border-b border-dotted border-slate-300 mb-7 pt-4" key={d.collection_id}>
<h3 className="text-xl leading-5 mb-5 font-medium">
{start + i}. <Link to={`/collections/${d._xxxid}`} className="text-rose-800 hover:underline">{d._xxxcollectionTitlextxt}</Link>
{start + i}. <Link to={`/collections/${d.collection_id}`} className="text-rose-800 hover:underline">{d.collection_title}</Link>
</h3>
<table className="mb-8 border-separate border-spacing-2">
<tbody>
{d._xxxcollectionDescriptionxtxt && <tr>
{d.collection_description && <tr>
<td className="text-slate-500 text-right align-text-top">Description:</td>
<td>{d._xxxcollectionDescriptionxtxt}</td>
<td>{d.collection_description}</td>
</tr>}
{d.scd_publish_status !== "collection-owner-title-description-only" && <>
{ctypes.length > 0 &&
Expand All @@ -37,22 +39,22 @@ const Results = ({results, start}: ResultProps) => (
<td>{ctypes.join("; ")}</td>
</tr>
}
{d._xcollectionFormatsxtxtxxxcollectionFormatsxtxt && <tr>
{d.collectionFormats && <tr>
<td className="text-slate-500 text-right align-text-top">Format:</td>
<td>{d._xcollectionFormatsxtxtxxxcollectionFormatsxtxt}</td>
<td>{d.collectionFormats}</td>
</tr>}
{d._xxxcollectionExtentxtxt && <tr>
{d.collection_extent && <tr>
<td className="text-slate-500 text-right align-text-top">Extent:</td>
<td>{d._xxxcollectionExtentxtxt}</td>
<td>{d.collection_extent}</td>
</tr>}
{d._xxxcollectionFindingAidUrlxtxt && <tr>
{d.collection_finding_aid_url && <tr>
<td className="text-slate-500 text-right align-text-top">Online finding aid:</td>
<td><a className="underline break-all" href={faURL}>View on {new URL(faURL).hostname}</a></td>
</tr>}
</>}
<tr>
<td className="text-slate-500 text-right align-text-top">Repository/Collector:</td>
<td>{d._xxxcollectionOwnerNamextxt}</td>
<td>{d.collection_holder_name}</td>
</tr>
</tbody>
</table>
Expand All @@ -78,12 +80,11 @@ const SearchPage: React.FC<PageProps> = ({data}) => {
const [facets, setFacets] = React.useState<Facet[]>([]);

const facetFields = new Map<string, string>([
["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
Expand All @@ -102,9 +103,9 @@ const SearchPage: React.FC<PageProps> = ({data}) => {
// sort then paginate
(facetedResults as DeepWritable<Queries.qSearchPageQuery["allAirtableScdItems"]["nodes"]>).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)
Expand Down Expand Up @@ -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
}
}
}
Expand Down
59 changes: 26 additions & 33 deletions src/templates/collection.tsx
Original file line number Diff line number Diff line change
@@ -1,96 +1,89 @@
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<PageProps> = ({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 (
<Layout>
<div className="w-full max-w-hlg md:flex-nowrap md:justify-start justify-between items-center px-4 m-auto">
<section className="px-0 mx-5">
<article className="pt-4" key={d._xxxid}>
<article className="pt-4" key={d.collection_id}>
<h2 className="text-4xl mb-5 font-medium">
{d._xxxcollectionTitlextxt}
{d.collection_title}
</h2>
<p className="text-red-800 underline"><Link to="/search">« Back to search</Link></p>
<table className="mb-8 border-separate border-spacing-2">
<tbody>
{d._xxxcollectionDescriptionxtxt && <tr>
{d.collection_description && <tr>
<td className="text-slate-500 text-right align-text-top">Description:</td>
<td>{d._xxxcollectionDescriptionxtxt}</td>
<td>{d.collection_description}</td>
</tr>}
{ // additional fields for public entries.
d.scd_publish_status !== "collection-owner-title-description-only" && <>
<tr>
<td className="text-slate-500 text-right align-text-top">Content type{ctypes.length > 1 ? 's': ''}:</td>
<td>{ctypes.join("; ")}</td>
</tr>
{genres.length > 0 &&
<tr>
<td className="text-slate-500 text-right align-text-top">Genre{genres.length > 1 ? 's': ''}:</td>
<td>{genres.join("; ")}</td>
</tr>
}
{d._xcollectionFormatsxtxtxxxcollectionFormatsxtxt && <tr>
{d.collectionFormats && <tr>
<td className="text-slate-500 text-right align-text-top">Format:</td>
<td>{d._xcollectionFormatsxtxtxxxcollectionFormatsxtxt}</td>
<td>{d.collectionFormats}</td>
</tr>}
{d._xxxcollectionExtentxtxt && <tr>
{d.collection_extent && <tr>
<td className="text-slate-500 text-right align-text-top">Extent:</td>
<td>{d._xxxcollectionExtentxtxt}</td>
<td>{d.collection_extent}</td>
</tr>}
{langs.length > 0 &&
<tr>
<td className="text-slate-500 text-right align-text-top">Language{langs.length > 1 ? 's': ''}:</td>
<td>{langs.join("; ")}</td>
</tr>
}
{d._xxxcollectionNotesxtxt &&
{d.collection_notes &&
<tr>
<td className="text-slate-500 text-right align-text-top">Additional notes:</td>
<td>{d._xxxcollectionNotesxtxt}</td>
<td>{d.collection_notes}</td>
</tr>
}
{d._xxxcollectionFindingAidUrlxtxt && <tr>
{d.collection_finding_aid_url && <tr>
<td className="text-slate-500 text-right align-text-top">Online finding aid:</td>
<td><a className="underline break-all" href={faURL}>View on {new URL(faURL).hostname}</a></td>
</tr>}
{d._xxxcollectionCatalogUrlxtxt && <tr>
{d.collection_catalog_url && <tr>
<td className="text-slate-500 text-right align-text-top">Online catalog:</td>
<td><a className="underline break-all" href={catURL}>View on {new URL(catURL).hostname}</a></td>
</tr>}
{d._xxxcollectionWebsiteUrlxtxt && <tr>
{d.collection_website_url && <tr>
<td className="text-slate-500 text-right align-text-top">Collection website:</td>
<td><a className="underline break-all" href={webURL}>View on {new URL(webURL).hostname}</a></td>
</tr>}
</>
}
<tr>
<td className="text-slate-500 text-right align-text-top">Repository/Collector:</td>
<td>{d._xxxcollectionOwnerNamextxt}</td>
<td>{d.collection_holder_name}</td>
</tr>
{ // additional fields for public entries.
d.scd_publish_status !== "collection-owner-title-description-only" && <>
<tr>
<td className="text-slate-500 text-right align-text-top">Location:</td>
<td>{loc.join(", ")}</td>
</tr>
{d._xxxcollectionUsageStatementxtxt &&
{d.collection_usage_statement &&
<tr>
<td className="text-slate-500 text-right align-text-top">Usage statement:</td>
<td>{d._xxxcollectionUsageStatementxtxt}</td>
<td>{d.collection_usage_statement}</td>
</tr>
}
</>}
Expand All @@ -105,4 +98,4 @@ const Collection: React.FC<PageProps> = ({pageContext}) => {

export default Collection

export const Head: HeadFC = ({pageContext}) => <title>{(pageContext as Queries.qCollectionsQuery["allAirtableScdItems"]["nodes"][0]["data"])?._xxxcollectionTitlextxt} | RPTF/ARSC Sound Collections Database</title>
export const Head: HeadFC = ({pageContext}) => <title>{(pageContext as Queries.qCollectionsQuery["allAirtableScdItems"]["nodes"][0]["data"])?.collection_title} | RPTF/ARSC Sound Collections Database</title>

0 comments on commit 3218132

Please sign in to comment.