Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add concept scheme to embedded concepts #295 #296

Merged
merged 3 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading