diff --git a/gatsby/lobid/src/components/helpers.js b/gatsby/lobid/src/components/helpers.js
index fc3685c..1a39388 100644
--- a/gatsby/lobid/src/components/helpers.js
+++ b/gatsby/lobid/src/components/helpers.js
@@ -1,3 +1,5 @@
+import React from "react";
+
export function simpleId(url) {
return url.slice(url.lastIndexOf("/") + 1);
}
@@ -5,3 +7,11 @@ export function simpleId(url) {
export function stripLobidOrg(url) {
return url.replace(/https?:\/\/lobid.org\//, '/');
}
+
+export function asLinks(field, entity, props) {
+ return entity[field] &&
{props[field]} | {entity[field].map((link) =>
+ )}
+ |
+}
diff --git a/gatsby/lobid/src/components/product.html.js b/gatsby/lobid/src/components/product.html.js
index 90c18f4..6435ca4 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 { simpleId, asLinks } from "./helpers.js";
import Header from "./header.html";
import Footer from "./footer.html";
@@ -19,13 +19,6 @@ export class Product extends React.Component {
this.props = props;
}
- asLinks(field) {
- return this.props.product[field] && {this.props[field]} | {this.props.product[field].map((link) => {
- let linkId = link.id.replace(/https?:\/\/lobid.org\//, '/');
- return
- })} |
- }
-
render() {
return (
@@ -43,7 +36,7 @@ export class Product extends React.Component {
{this.props.product.name.label}
- {this.props.product.slogan && [this.props.product.slogan].map(s => — {s.label})}
+ {this.props.product.slogan && [this.props.product.slogan].map(s => — {s.label})}
@@ -57,9 +50,9 @@ export class Product extends React.Component {
Website | {this.props.product.url || this.props.product.id} |
- {this.asLinks("hasPart")}
- {this.asLinks("isBasedOn")}
- {this.asLinks("isRelatedTo")}
+ {asLinks("hasPart", this.props.product, this.props)}
+ {asLinks("isBasedOn", this.props.product, this.props)}
+ {asLinks("isRelatedTo", this.props.product, this.props)}
diff --git a/gatsby/lobid/src/components/project.html.js b/gatsby/lobid/src/components/project.html.js
index 5037db8..21d5d6b 100644
--- a/gatsby/lobid/src/components/project.html.js
+++ b/gatsby/lobid/src/components/project.html.js
@@ -1,6 +1,6 @@
import React from "react";
import md5 from "md5";
-import { simpleId } from "./helpers.js";
+import { simpleId, asLinks } from "./helpers.js";
import Header from "./header.html";
import Footer from "./footer.html";
@@ -19,14 +19,6 @@ export class Project extends React.Component {
this.props = props;
}
- asLinks(field) {
- return this.props.project[field] && {this.props[field]} | {this.props.project[field].map((link) => {
- let linkId = link.id.replace(/https?:\/\/lobid.org\//, '/');
- return
- }
- )} |
- }
-
render() {
return (
@@ -44,7 +36,7 @@ export class Project extends React.Component {
{this.props.project.name.label}
- {this.props.project.alternateName && this.props.project.alternateName.map(s => | {s})}
+ {this.props.project.alternateName && this.props.project.alternateName.map(s => | {s})}
@@ -59,11 +51,11 @@ export class Project extends React.Component {
Website | {this.props.project.url || this.props.project.id} |
{this.props.project.endDate && Abgeschlossen | {this.props.project.endDate} |
}
- {this.asLinks("hasPart")}
- {this.asLinks("isBasedOn")}
- {this.asLinks("isRelatedTo")}
- {this.asLinks("enhances")}
- {this.asLinks("result")}
+ {asLinks("hasPart", this.props.project, this.props)}
+ {asLinks("isBasedOn", this.props.project, this.props)}
+ {asLinks("isRelatedTo", this.props.project, this.props)}
+ {asLinks("enhances", this.props.project, this.props)}
+ {asLinks("result", this.props.project, this.props)}