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 skos:related links #106

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 3 additions & 2 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ exports.sourceNodes = async ({
const compacted = await jsonld.compact(doc, context.jsonld)
compacted['@graph'].forEach((graph, i) => {
const {
narrower, narrowerTransitive, broader, broaderTransitive, inScheme, topConceptOf,
hasTopConcept, ...properties
narrower, narrowerTransitive, broader, broaderTransitive, related,
inScheme, topConceptOf, hasTopConcept, ...properties
} = graph
const type = Array.isArray(properties.type)
? properties.type.find(t => ['Concept', 'ConceptScheme'])
Expand All @@ -71,6 +71,7 @@ exports.sourceNodes = async ({
hasTopConcept___NODE: (hasTopConcept || []).map(topConcept => topConcept.id),
broader___NODE: (broader && broader.id) || null,
broaderTransitive___NODE: (broaderTransitive && broaderTransitive.id) || null,
related___NODE: (related || []).map(related => related.id),
internal: {
contentDigest: createContentDigest(graph),
type,
Expand Down
19 changes: 18 additions & 1 deletion src/components/Concept.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/** @jsx jsx */
import { jsx } from '@emotion/core'
import Markdown from 'markdown-to-jsx'
import { Link } from 'gatsby'

import { t, getDomId } from '../common'
import { t, getDomId, getFilePath } from '../common'

const Concept = ({ pageContext: { node: concept } }) => (
<div className="content block" id={getDomId(concept.id)}>
Expand Down Expand Up @@ -46,6 +47,22 @@ const Concept = ({ pageContext: { node: concept } }) => (
</div>
)
}
{concept.related
&& (
<div>
<h3>Related</h3>
<ul>
{concept.related.map(related => (
<li key={related.id}>
<Link to={getFilePath(related.id, 'html')}>
{t(related.prefLabel)}
</Link>
</li>
))}
</ul>
</div>
)
}
</div>
)

Expand Down
3 changes: 3 additions & 0 deletions src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const jsonld = {
"narrower": {
"@container": "@set"
},
"related": {
"@container": "@set"
},
"narrowerTransitive": {
"@container": "@set"
},
Expand Down
6 changes: 6 additions & 0 deletions src/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ module.exports.allConcept = (inScheme, languages) => `
${[...languages].join(' ')}
}
}
related {
id
prefLabel {
${[...languages].join(' ')}
}
}
inScheme {
id
title {
Expand Down
1 change: 1 addition & 0 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = languages => `
narrowerTransitive: [Concept] @link(from: "narrowerTransitive___NODE"),
broader: Concept @link(from: "broader___NODE"),
broaderTransitive: [Concept] @link(from: "broaderTransitive___NODE"),
related: [Concept] @link(from: "related___NODE"),
inScheme: ConceptScheme! @link(from: "inScheme___NODE"),
hub: String,
inbox: String
Expand Down