Skip to content

Commit

Permalink
Add concept scheme to embedded concepts #295
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sroertgen committed Apr 9, 2024
1 parent b7d07de commit 254ba85
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions cypress/e2e/conceptSchemeAndConcept.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion src/components/Concept.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const Concept = ({
</h1>
<h1>
{concept.notation && <span>{concept.notation.join(",")}&nbsp;</span>}
{i18n(language)(concept.prefLabel)}
{(concept?.prefLabel && i18n(language)(concept.prefLabel)) ||
(concept?.title && i18n(language)(concept.title))}
</h1>
<ConceptURI id={concept.id} />
<JsonLink to={getFilePath(concept.id, "json", customDomain)} />
Expand Down

0 comments on commit 254ba85

Please sign in to comment.