From 254ba85f2ef5c2b8ebd7abc89713c148138b7bc2 Mon Sep 17 00:00:00 2001 From: "@s.roertgen" Date: Tue, 9 Apr 2024 12:18:26 +0200 Subject: [PATCH 1/2] Add concept scheme to embedded concepts #295 The concept scheme was not yet added to the embedded concepts for hash uris. If visiting a hash uri concept scheme directly this resulted in a crash. --- cypress/e2e/conceptSchemeAndConcept.cy.js | 10 ++++++++++ gatsby-node.js | 9 ++++++++- src/components/Concept.jsx | 3 ++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/conceptSchemeAndConcept.cy.js b/cypress/e2e/conceptSchemeAndConcept.cy.js index 97ec3fe..7689c06 100644 --- a/cypress/e2e/conceptSchemeAndConcept.cy.js +++ b/cypress/e2e/conceptSchemeAndConcept.cy.js @@ -64,6 +64,16 @@ describe("Concept Scheme and Concept", () => { cy.get("h1").should("have.text", "Hash URI Konzept Schema") }) + it("Visting a hash URI Concept Scheme with hash uri in URL works", () => { + cy.visit("/example.org/hashURIConceptScheme.html#scheme", { + onBeforeLoad(win) { + Object.defineProperty(win.navigator, "language", { value: "de-DE" }) + }, + }) + cy.get(".conceptScheme > a").should("have.text", "Hash URI Konzept Schema") + cy.get("h1").should("have.text", "Hash URI Konzept Schema") + }) + it("Visting a hash URI Concept works", () => { cy.visit("/example.org/hashURIConceptScheme.html#concept1", { onBeforeLoad(win) { diff --git a/gatsby-node.js b/gatsby-node.js index 04fa0d7..2703fff 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -306,7 +306,14 @@ exports.createPages = async ({ graphql, actions: { createPage } }) => { const conceptsInScheme = await graphql( queries.allConcept(conceptScheme.id, languages) ) - const embeddedConcepts = [] + // embed concept scheme data + const embeddedConcepts = [ + { + json: omitEmpty(Object.assign({}, conceptScheme, context.jsonld)), + jsonld: omitEmpty(Object.assign({}, conceptScheme, context.jsonld)), + }, + ] + conceptsInScheme.data.allConcept.edges.forEach(({ node: concept }) => { const json = omitEmpty(Object.assign({}, concept, context.jsonld)) const jsonld = omitEmpty(Object.assign({}, concept, context.jsonld)) diff --git a/src/components/Concept.jsx b/src/components/Concept.jsx index 58702c9..45541cb 100644 --- a/src/components/Concept.jsx +++ b/src/components/Concept.jsx @@ -25,7 +25,8 @@ const Concept = ({

{concept.notation && {concept.notation.join(",")} } - {i18n(language)(concept.prefLabel)} + {(concept?.prefLabel && i18n(language)(concept.prefLabel)) || + (concept?.title && i18n(language)(concept.title))}

From fa91c4a91da1dee0eb1c9e371c8b9650c669fc24 Mon Sep 17 00:00:00 2001 From: "@s.roertgen" Date: Tue, 23 Apr 2024 11:17:53 +0200 Subject: [PATCH 2/2] Align display of hash uri and slash uri concepts #295 Moves the CSS out of the component and thereby aligns the display of concepts, conept schemes and collections. --- src/components/Collection.jsx | 2 +- src/components/Concept.jsx | 2 +- src/components/ConceptScheme.jsx | 10 ++-------- src/templates/App.jsx | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/Collection.jsx b/src/components/Collection.jsx index 4dcd86b..5556116 100644 --- a/src/components/Collection.jsx +++ b/src/components/Collection.jsx @@ -15,7 +15,7 @@ const Collection = ({ pageContext: { node: collection, customDomain } }) => { }, [data?.selectedLanguage]) return ( -
+

{i18n(language)(collection.prefLabel)}

{collection.id}

diff --git a/src/components/Concept.jsx b/src/components/Concept.jsx index e263591..b148571 100644 --- a/src/components/Concept.jsx +++ b/src/components/Concept.jsx @@ -19,7 +19,7 @@ const Concept = ({ }, [data?.selectedLanguage]) return ( -
+

{concept.deprecated ? "Deprecated" : ""}

diff --git a/src/components/ConceptScheme.jsx b/src/components/ConceptScheme.jsx index 801f4d3..9ee48ca 100644 --- a/src/components/ConceptScheme.jsx +++ b/src/components/ConceptScheme.jsx @@ -22,19 +22,13 @@ const ConceptScheme = ({ if (pathname.hash) { const filtered = embed.filter((c) => c.json.id.endsWith(pathname.hash)) return ( -
+
) } else { return ( -
+

{i18n(language)(conceptScheme.title)}

diff --git a/src/templates/App.jsx b/src/templates/App.jsx index 52d8d9e..b9a6c93 100644 --- a/src/templates/App.jsx +++ b/src/templates/App.jsx @@ -198,7 +198,7 @@ const App = ({ pageContext, children, location }) => { )}
- {children} +
{children}
)