Skip to content

Commit

Permalink
Merge pull request #296 from skohub-io/295-scheme-suffix
Browse files Browse the repository at this point in the history
Add concept scheme to embedded concepts #295
  • Loading branch information
sroertgen authored Apr 24, 2024
2 parents cd4b4d7 + fa91c4a commit cf08bc9
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 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 @@ -299,7 +299,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
2 changes: 1 addition & 1 deletion src/components/Collection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Collection = ({ pageContext: { node: collection, customDomain } }) => {
}, [data?.selectedLanguage])

return (
<div className="content block main-block">
<div>
<h1>{i18n(language)(collection.prefLabel)}</h1>
<h2>{collection.id}</h2>
<JsonLink to={getFilePath(collection.id, "json", customDomain)} />
Expand Down
5 changes: 3 additions & 2 deletions src/components/Concept.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ const Concept = ({
}, [data?.selectedLanguage])

return (
<div className="content block main-block" id={getDomId(concept.id)}>
<div id={getDomId(concept.id)}>
<h1 style={{ color: config.colors.skoHubAction }}>
{concept.deprecated ? "Deprecated" : ""}
</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
10 changes: 2 additions & 8 deletions src/components/ConceptScheme.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,13 @@ const ConceptScheme = ({
if (pathname.hash) {
const filtered = embed.filter((c) => c.json.id.endsWith(pathname.hash))
return (
<div
className="content concept block main-block"
id={getDomId(conceptScheme.id)}
>
<div id={getDomId(conceptScheme.id)}>
<Concept pageContext={{ node: filtered[0].json, language }} />
</div>
)
} else {
return (
<div
className="content concept block main-block"
id={getDomId(conceptScheme.id)}
>
<div id={getDomId(conceptScheme.id)}>
<div>
<h1>{i18n(language)(conceptScheme.title)}</h1>
<ConceptURI id={conceptScheme.id} />
Expand Down
2 changes: 1 addition & 1 deletion src/templates/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const App = ({ pageContext, children, location }) => {
)}
</div>
</nav>
{children}
<div className="content concept block main-block">{children}</div>
</div>
</Layout>
)
Expand Down

0 comments on commit cf08bc9

Please sign in to comment.