diff --git a/gatsby/lobid/gatsby-config.js b/gatsby/lobid/gatsby-config.js index ab84732..5b2851c 100644 --- a/gatsby/lobid/gatsby-config.js +++ b/gatsby/lobid/gatsby-config.js @@ -31,6 +31,12 @@ module.exports = { path: `${__dirname}/static/product/`, } }, + { + resolve: `gatsby-source-filesystem`, + options: { + path: `${__dirname}/static/project/`, + } + }, `gatsby-transformer-sharp`, `gatsby-plugin-sharp` ], diff --git a/gatsby/lobid/gatsby-node.js b/gatsby/lobid/gatsby-node.js index 67073d7..fe97aca 100644 --- a/gatsby/lobid/gatsby-node.js +++ b/gatsby/lobid/gatsby-node.js @@ -63,6 +63,27 @@ exports.createPages = async ({ graphql, actions }) => { .map(id => id.slice(id.lastIndexOf("/") + 1, id.lastIndexOf("."))); addPages(shortProductIds, "product", "./src/templates/product.js", createPage); + // Pages for individual project files in /project + + const { + data: { projects }, + } = await graphql(` + { + projects: allProjectJson { + edges { + node { + id + } + } + } + } + `); + + const shortProjectIds = projects.edges.map(e => e.node.id) + .filter(id => id.indexOf("/") != -1) + .map(id => id.slice(id.lastIndexOf("/") + 1)); + addPages(shortProjectIds, "project", "./src/templates/project.js", createPage); + }; // Create `fields.jsonFile` fields to link to static publication JSON files @@ -86,11 +107,11 @@ exports.onCreateNode = ({ node, getNode, actions }) => { function addPages(ids, prefix, template, createPage) { const unique = [...new Set(ids)]; - unique.forEach((member) => { + unique.forEach((entityId) => { createPage({ - path: `/${prefix}/${member}`, + path: `/${prefix}/${entityId}`, component: path.resolve(template), - context: { id: member }, + context: { id: entityId }, }); }); } diff --git a/gatsby/lobid/src/components/helpers.js b/gatsby/lobid/src/components/helpers.js index 76899cd..158c7ea 100644 --- a/gatsby/lobid/src/components/helpers.js +++ b/gatsby/lobid/src/components/helpers.js @@ -1,3 +1,7 @@ -export function simpleId(url) { +export function simpleProductId(url) { return url.slice(url.lastIndexOf("/") + 1, url.lastIndexOf(".")); } + +export function simpleProjectId(url) { + return url.slice(url.lastIndexOf('/')+1); +} diff --git a/gatsby/lobid/src/components/product.html.js b/gatsby/lobid/src/components/product.html.js index 6e699b9..d75dbe0 100644 --- a/gatsby/lobid/src/components/product.html.js +++ b/gatsby/lobid/src/components/product.html.js @@ -1,6 +1,6 @@ import React from "react"; import md5 from 'md5'; -import { simpleId } from './helpers.js' +import { simpleProductId } from './helpers.js' import Header from "./header.html"; import Footer from "./footer.html"; @@ -42,14 +42,14 @@ export class Product extends React.Component {

{this.props.product.name.label} - {this.props.product.slogan && [this.props.product.slogan].map(s => — {s.label})} - JSON-LD + {this.props.product.slogan && [this.props.product.slogan].map(s => — {s.label})} + JSON-LD

-

{this.props.product.description.label}

+

{this.props.product.description.label}

diff --git a/gatsby/lobid/src/components/project.html.js b/gatsby/lobid/src/components/project.html.js new file mode 100644 index 0000000..9f961fc --- /dev/null +++ b/gatsby/lobid/src/components/project.html.js @@ -0,0 +1,79 @@ +import React from "react"; +import md5 from 'md5'; +import { simpleProjectId } from './helpers.js' + +import Header from "./header.html"; +import Footer from "./footer.html"; +import Publications from "./publications.html"; + +import "./css/lobid.css"; +import "./css/bootstrap.min.css"; +import "./css/font-awesome.min.css"; + +import jsonLdPng from "./images/json-ld.png"; + +export class Project extends React.Component { + + constructor(props) { + super(props); + this.props = props; + } + + asLinks(field) { + return this.props.project[field] && + } + + render() { + return ( +
+

+

+
+
+

+ {this.props.project.name.label} + + {this.props.project.alternateName && this.props.project.alternateName.map(s => | {s})} + JSON-LD +

+
+ +
+
+

{this.props.project.description.label}

+
{this.props[field]}{this.props.project[field].map((link) => + + )}
+ + + + + + {this.props.project.endDate && } + {this.asLinks("hasPart")} + {this.asLinks("isBasedOn")} + {this.asLinks("isRelatedTo")} + {this.asLinks("enhances")} + {this.asLinks("result")} + + +
Website{this.props.project.id}
Abgeschlossen{this.props.project.endDate}
+
+
+ {this.props.project.name.label} +
+
+ +