-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgridsome.server.js
69 lines (59 loc) · 2.5 KB
/
gridsome.server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const fs = require("fs");
const path = require("path");
const pick = require("lodash.pick");
const sargonObjects = require("./static/ontology/all_objects.json");
const { pathPrefix } = require("./gridsome.config");
const cacheVersion = new Date().getTime();
module.exports = function (api, options) {
api.loadSource((store) => {
const cleanedPathPrefix = `${
pathPrefix
? ["", ...pathPrefix.split("/").filter((dir) => dir.length)].join("/")
: ""
}`;
store.addMetadata("pathPrefix", cleanedPathPrefix);
store.addMetadata("cacheVersion", cacheVersion);
const classes = store.addCollection({
typeName: "Class",
});
const relationships = store.addCollection({
typeName: "Relationship",
});
const namespaces = store.addCollection({
typeName: "Namespace",
});
sargonObjects.forEach((node) => {
if (node.path.charAt(0) == "/")
classes.addNode({
id: node.id,
name: node.name,
version: node.version,
type: node.type,
types: node.types,
namespace: store.createReference("Namespace", node.namespace),
path: node.path,
labels: node.labels,
rdfs_label: node.rdfs_label,
generatedLabel: node.generatedLabel,
generatedAlias: node.generatedAlias,
superclasses: store.createReference("Class", node.superclasses),
subclasses: store.createReference("Class", node.subclasses),
comments: node.comments,
definitions: node.definitions,
skos_notes: node.skos_notes,
skos_historyNotes: node.skos_historyNotes,
equivalentClasses: store.createReference(
"Class",
node.equivalentClasses
),
hierarchy: node.hierarchy,
inRangeOf: store.createReference("Class", node.inRangeOf),
relations: store.createReference("Class", node.relations),
inDomainOf: store.createReference("Class", node.inDomainOf),
});
});
});
api.beforeBuild(({ config, store }) => {
// Generate an index file for Fuse to search webpages
});
};