Skip to content

Commit cf08bc9

Browse files
authored
Merge pull request #296 from skohub-io/295-scheme-suffix
Add concept scheme to embedded concepts #295
2 parents cd4b4d7 + fa91c4a commit cf08bc9

File tree

6 files changed

+25
-13
lines changed

6 files changed

+25
-13
lines changed

cypress/e2e/conceptSchemeAndConcept.cy.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ describe("Concept Scheme and Concept", () => {
6464
cy.get("h1").should("have.text", "Hash URI Konzept Schema")
6565
})
6666

67+
it("Visting a hash URI Concept Scheme with hash uri in URL works", () => {
68+
cy.visit("/example.org/hashURIConceptScheme.html#scheme", {
69+
onBeforeLoad(win) {
70+
Object.defineProperty(win.navigator, "language", { value: "de-DE" })
71+
},
72+
})
73+
cy.get(".conceptScheme > a").should("have.text", "Hash URI Konzept Schema")
74+
cy.get("h1").should("have.text", "Hash URI Konzept Schema")
75+
})
76+
6777
it("Visting a hash URI Concept works", () => {
6878
cy.visit("/example.org/hashURIConceptScheme.html#concept1", {
6979
onBeforeLoad(win) {

gatsby-node.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,14 @@ exports.createPages = async ({ graphql, actions: { createPage } }) => {
299299
const conceptsInScheme = await graphql(
300300
queries.allConcept(conceptScheme.id, languages)
301301
)
302-
const embeddedConcepts = []
302+
// embed concept scheme data
303+
const embeddedConcepts = [
304+
{
305+
json: omitEmpty(Object.assign({}, conceptScheme, context.jsonld)),
306+
jsonld: omitEmpty(Object.assign({}, conceptScheme, context.jsonld)),
307+
},
308+
]
309+
303310
conceptsInScheme.data.allConcept.edges.forEach(({ node: concept }) => {
304311
const json = omitEmpty(Object.assign({}, concept, context.jsonld))
305312
const jsonld = omitEmpty(Object.assign({}, concept, context.jsonld))

src/components/Collection.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const Collection = ({ pageContext: { node: collection, customDomain } }) => {
1515
}, [data?.selectedLanguage])
1616

1717
return (
18-
<div className="content block main-block">
18+
<div>
1919
<h1>{i18n(language)(collection.prefLabel)}</h1>
2020
<h2>{collection.id}</h2>
2121
<JsonLink to={getFilePath(collection.id, "json", customDomain)} />

src/components/Concept.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ const Concept = ({
1919
}, [data?.selectedLanguage])
2020

2121
return (
22-
<div className="content block main-block" id={getDomId(concept.id)}>
22+
<div id={getDomId(concept.id)}>
2323
<h1 style={{ color: config.colors.skoHubAction }}>
2424
{concept.deprecated ? "Deprecated" : ""}
2525
</h1>
2626
<h1>
2727
{concept.notation && <span>{concept.notation.join(",")}&nbsp;</span>}
28-
{i18n(language)(concept.prefLabel)}
28+
{(concept?.prefLabel && i18n(language)(concept.prefLabel)) ||
29+
(concept?.title && i18n(language)(concept.title))}
2930
</h1>
3031
<ConceptURI id={concept.id} />
3132
<JsonLink to={getFilePath(concept.id, "json", customDomain)} />

src/components/ConceptScheme.jsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,13 @@ const ConceptScheme = ({
2222
if (pathname.hash) {
2323
const filtered = embed.filter((c) => c.json.id.endsWith(pathname.hash))
2424
return (
25-
<div
26-
className="content concept block main-block"
27-
id={getDomId(conceptScheme.id)}
28-
>
25+
<div id={getDomId(conceptScheme.id)}>
2926
<Concept pageContext={{ node: filtered[0].json, language }} />
3027
</div>
3128
)
3229
} else {
3330
return (
34-
<div
35-
className="content concept block main-block"
36-
id={getDomId(conceptScheme.id)}
37-
>
31+
<div id={getDomId(conceptScheme.id)}>
3832
<div>
3933
<h1>{i18n(language)(conceptScheme.title)}</h1>
4034
<ConceptURI id={conceptScheme.id} />

src/templates/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ const App = ({ pageContext, children, location }) => {
198198
)}
199199
</div>
200200
</nav>
201-
{children}
201+
<div className="content concept block main-block">{children}</div>
202202
</div>
203203
</Layout>
204204
)

0 commit comments

Comments
 (0)