diff --git a/src/pages/search.tsx b/src/pages/search.tsx
index 56822bf6b..8fafa05a4 100644
--- a/src/pages/search.tsx
+++ b/src/pages/search.tsx
@@ -37,25 +37,25 @@ const Results = ({results, fieldLabels, start}: ResultProps) => {
{d.collection_description &&
{getLabel('collection_description')}: |
- {d.collection_description} |
+ {d.collection_description} |
}
{d.scd_publish_status !== "collection-owner-title-description-only" && <>
- {d.physical_formats &&
+ {(d.physical_formats || []).length > 0 &&
{getLabel('physical_formats')}: |
- {d.physical_formats} |
+ {d.physical_formats?.join("; ")} |
}
{d.extent &&
{getLabel('extent')}: |
- {d.extent} |
+ {d.extent} |
}
{d.finding_aid_url &&
{getLabel('finding_aid_url')}: |
- View on {new URL(faURL).hostname} |
+ View on {new URL(faURL).hostname} |
}
>}
{getLabel('collection_holder_name')}: |
- {d.collection_holder_name} |
+ {d.collection_holder_name} |
@@ -73,10 +73,6 @@ const SearchPage: React.FC = ({data}) => {
const results = (data as Queries.qSearchPageQuery).allAirtableScdItems.nodes
const [currentPage, setCurrentPage] = React.useState(1)
const [resultsPerPage, setResultsPerPage] = React.useState(20)
- const startIndex = (currentPage - 1) * resultsPerPage
- const endIndex = startIndex + resultsPerPage
- const totalPages = Math.ceil(results.length / resultsPerPage)
-
const [sortOrder, setSortOrder] = React.useState("asc");
const [facets, setFacets] = React.useState([]);
@@ -110,6 +106,11 @@ const SearchPage: React.FC = ({data}) => {
return b.data!.collection_title!.localeCompare(a.data!.collection_title!)
}
})
+
+ const totalPages = Math.ceil(facetedResults.length / resultsPerPage)
+ const startIndex = (currentPage - 1) * resultsPerPage
+ const endIndex = Math.min(startIndex + resultsPerPage, facetedResults.length)
+
const paginatedResults = facetedResults.slice(startIndex, endIndex)
// Update component with existing query parameters on load
diff --git a/src/templates/collection.tsx b/src/templates/collection.tsx
index 4f916a33c..bd5e41b29 100644
--- a/src/templates/collection.tsx
+++ b/src/templates/collection.tsx
@@ -23,11 +23,22 @@ const Collection: React.FC = ({pageContext}) => {
const subjects = d.subjects || []
const formats = d.physical_formats || []
const langs = d.languages || []
+ const contentCats = d.collection_content_category || []
+ const holderCats = d.collection_holder_category || []
+ const invDesc = d.inventory_description || []
+ const creators = d.creators || []
const loc = []
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;
+ const Field = ({label, value}: {label: string, value: string}) => {
+ return
+ {getLabel(label)}: |
+ {value} |
+
+ }
+
return (
@@ -39,98 +50,42 @@ const Collection: React.FC
= ({pageContext}) => {
« Back to search
- {d.collection_description &&
- {getLabel("collection_description")}: |
- {d.collection_description} |
-
}
{ // additional fields for public entries.
d.scd_publish_status !== "collection-owner-title-description-only" && <>
- {d.record_type &&
- {getLabel("record_type")}: |
- {d.record_type} |
-
}
- {ctypes.length > 0 &&
+ {d.record_type && }
+ {contentCats.length > 0 && }
+ >}
+ {d.collection_description && }
+ { // additional fields for public entries.
+ d.scd_publish_status !== "collection-owner-title-description-only" && <>
+ {holderCats && }
+ >}
+
+ { // additional fields for public entries.
+ d.scd_publish_status !== "collection-owner-title-description-only" && <>
- {getLabel("content_types")}: |
- {ctypes.join("; ")} |
+ Location: |
+ {loc.join(", ")} |
- }
- {d.collection_content_category &&
- {getLabel("collection_content_category")}: |
- {d.collection_content_category} |
-
}
- {d.collection_holder_category &&
- {getLabel("collection_holder_category")}: |
- {d.collection_holder_category} |
-
}
- {d.extent &&
- {getLabel("extent")}: |
- {d.extent} |
-
}
- {d.dates &&
- {getLabel("dates")}: |
- {d.dates} |
-
}
- {d.historical_relevance &&
- {getLabel("historical_relevance")}: |
- {d.historical_relevance} |
-
}
- {subjects.length > 0 &&
-
- {getLabel("subjects")}: |
- {subjects.join("; ")} |
-
- }
- {d.creators &&
- {getLabel("creators")}: |
- {d.creators} |
-
}
- {formats.length > 0 &&
- {getLabel("physical_formats")}: |
- {formats} |
-
}
- {langs.length > 0 &&
-
- {getLabel("languages")}: |
- {langs.join("; ")} |
-
- }
+ {ctypes.length > 0 && }
+ {d.dates && }
+ {d.extent && }
+ {d.historical_relevance && }
+ {subjects.length > 0 && }
+ {creators.length > 0 && }
+ {formats.length > 0 && }
+ {d.access_statement && }
{d.finding_aid_url &&
{getLabel("finding_aid_url")}: |
- View on {new URL(faURL).hostname} |
+ View on {new URL(faURL).hostname} |
}
- {d.supporting_documentation &&
-
- {getLabel("supporting_documentation")}: |
- {d.supporting_documentation} |
-
- }
- {d.inventory_description &&
-
- {getLabel("inventory_description")}: |
- {d.inventory_description} |
-
- }
{d.collection_catalog_url &&
Online catalog: |
- View on {new URL(catURL).hostname} |
-
}
- >
- }
-
- Repository/Collector: |
- {d.collection_holder_name} |
-
- { // additional fields for public entries.
- d.scd_publish_status !== "collection-owner-title-description-only" && <>
-
- Location: |
- {loc.join(", ")} |
-
- {d.access_statement &&
- {getLabel("access_statement")}: |
- {d.access_statement} |
+ View on {new URL(catURL).hostname} |
}
+ {d.supporting_documentation && }
+ {langs.length > 0 && }
+ {invDesc.length > 0 && }
>}