Skip to content

Commit 0223f68

Browse files
committed
pages for collections
1 parent 165a671 commit 0223f68

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

src/templates/collection.tsx

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import * as React from "react"
2+
import { graphql, Link, type HeadFC, type PageProps } from "gatsby"
3+
import Layout from "../components/Layout"
4+
5+
const Collection: React.FC<PageProps> = ({pageContext}) => {
6+
const data = pageContext as Queries.qCollectionsQuery["allAirtableScdItems"]["nodes"][0]["data"]
7+
const d = data!
8+
const faURL = d._xxxcollectionFindingAidUrlxtxt && d._xxxcollectionFindingAidUrlxtxt.startsWith("http") ? d._xxxcollectionFindingAidUrlxtxt : `http://${d._xxxcollectionFindingAidUrlxtxt}`
9+
const catURL = d._xxxcollectionCatalogUrlxtxt && d._xxxcollectionCatalogUrlxtxt.startsWith("http") ? d._xxxcollectionCatalogUrlxtxt : `http://${d._xxxcollectionCatalogUrlxtxt}`
10+
const webURL = d._xxxcollectionWebsiteUrlxtxt && d._xxxcollectionWebsiteUrlxtxt.startsWith("http") ? d._xxxcollectionWebsiteUrlxtxt : `http://${d._xxxcollectionWebsiteUrlxtxt}`
11+
const ctypes = d._xxxcollectionContentTypesxtxtxxxcollectionContentTypesxtxt || []
12+
const genres = d._xxxcollectionGenresxtxtxxxcollectionGenresxtxt || []
13+
const langs = d._xxxcollectionLanguagesxtxtxxxcollectionLanguagesxtxt || []
14+
const loc = []
15+
d._xxxcollectionOwnerLocationCityxtxt ? loc.push(d._xxxcollectionOwnerLocationCityxtxt) : false;
16+
d._xxxcollectionOwnerLocationStatextxt ? loc.push(d._xxxcollectionOwnerLocationStatextxt) : false;
17+
d._xxxcollectionOwnerLocationCountryxtxt ? loc.push(d._xxxcollectionOwnerLocationCountryxtxt) : false;
18+
19+
return (
20+
<Layout>
21+
<div className="w-full max-w-hlg md:flex-nowrap md:justify-start justify-between items-center px-4 m-auto">
22+
<section className="px-0 mx-5">
23+
<article className="pt-4" key={d._xxxid}>
24+
<h2 className="text-4xl mb-5 font-medium">
25+
{d._xxxcollectionTitlextxt}
26+
</h2>
27+
<p className="text-red-800 underline"><Link to="/search">« Back to search</Link></p>
28+
<table className="mb-8 border-separate border-spacing-2">
29+
<tbody>
30+
{d._xxxcollectionDescriptionxtxt && <tr>
31+
<td className="text-slate-500 text-right align-text-top">Description:</td>
32+
<td>{d._xxxcollectionDescriptionxtxt}</td>
33+
</tr>}
34+
{ // additional fields for public entries.
35+
d.scd_publish_status !== "collection-owner-title-description-only" && <>
36+
<tr>
37+
<td className="text-slate-500 text-right align-text-top">Content type{ctypes.length > 1 ? 's': ''}:</td>
38+
<td>{ctypes.join("; ")}</td>
39+
</tr>
40+
{genres.length > 0 &&
41+
<tr>
42+
<td className="text-slate-500 text-right align-text-top">Genre{genres.length > 1 ? 's': ''}:</td>
43+
<td>{genres.join("; ")}</td>
44+
</tr>
45+
}
46+
{d._xcollectionFormatsxtxtxxxcollectionFormatsxtxt && <tr>
47+
<td className="text-slate-500 text-right align-text-top">Format:</td>
48+
<td>{d._xcollectionFormatsxtxtxxxcollectionFormatsxtxt}</td>
49+
</tr>}
50+
{d._xxxcollectionExtentxtxt && <tr>
51+
<td className="text-slate-500 text-right align-text-top">Extent:</td>
52+
<td>{d._xxxcollectionExtentxtxt}</td>
53+
</tr>}
54+
{langs.length > 0 &&
55+
<tr>
56+
<td className="text-slate-500 text-right align-text-top">Language{langs.length > 1 ? 's': ''}:</td>
57+
<td>{langs.join("; ")}</td>
58+
</tr>
59+
}
60+
{d._xxxcollectionNotesxtxt &&
61+
<tr>
62+
<td className="text-slate-500 text-right align-text-top">Additional notes:</td>
63+
<td>{d._xxxcollectionNotesxtxt}</td>
64+
</tr>
65+
}
66+
{d._xxxcollectionFindingAidUrlxtxt && <tr>
67+
<td className="text-slate-500 text-right align-text-top">Online finding aid:</td>
68+
<td><a className="underline break-all" href={faURL}>View on {new URL(faURL).hostname}</a></td>
69+
</tr>}
70+
{d._xxxcollectionCatalogUrlxtxt && <tr>
71+
<td className="text-slate-500 text-right align-text-top">Online catalog:</td>
72+
<td><a className="underline break-all" href={catURL}>View on {new URL(catURL).hostname}</a></td>
73+
</tr>}
74+
{d._xxxcollectionWebsiteUrlxtxt && <tr>
75+
<td className="text-slate-500 text-right align-text-top">Collection website:</td>
76+
<td><a className="underline break-all" href={webURL}>View on {new URL(webURL).hostname}</a></td>
77+
</tr>}
78+
</>
79+
}
80+
<tr>
81+
<td className="text-slate-500 text-right align-text-top">Repository/Collector:</td>
82+
<td>{d._xxxcollectionOwnerNamextxt}</td>
83+
</tr>
84+
{ // additional fields for public entries.
85+
d.scd_publish_status !== "collection-owner-title-description-only" && <>
86+
<tr>
87+
<td className="text-slate-500 text-right align-text-top">Location:</td>
88+
<td>{loc.join(", ")}</td>
89+
</tr>
90+
{d._xxxcollectionUsageStatementxtxt &&
91+
<tr>
92+
<td className="text-slate-500 text-right align-text-top">Usage statement:</td>
93+
<td>{d._xxxcollectionUsageStatementxtxt}</td>
94+
</tr>
95+
}
96+
</>}
97+
</tbody>
98+
</table>
99+
</article>
100+
</section>
101+
</div>
102+
</Layout>
103+
)
104+
}
105+
106+
export default Collection
107+
108+
export const Head: HeadFC = ({pageContext}) => <title>{(pageContext as Queries.qCollectionsQuery["allAirtableScdItems"]["nodes"][0]["data"])?._xxxcollectionTitlextxt} | RPTF/ARSC Sound Collections Database</title>

0 commit comments

Comments
 (0)