-
Notifications
You must be signed in to change notification settings - Fork 0
/
gridsome.server.js
42 lines (35 loc) · 1.13 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
// Data
const skills = require("./content/skills/skills.json");
const siteMetadata = require("./src/data/siteMetadata.json");
function slugify(text) {
return text
.toString()
.toLowerCase()
.replace(/\s+/g, "-") // Replace spaces with -
.replace(/[^\w-]+/g, "") // Remove all non-word chars
.replace(/--+/g, "-") // Replace multiple - with single -
.replace(/^-+/, "") // Trim - from start of text
.replace(/-+$/, ""); // Trim - from end of text
}
module.exports = function (api) {
api.loadSource(({ addMetadata }) => {
const gitCommit = process.env.COMMIT_REF
? process.env.COMMIT_REF.slice(0, 7)
: "N/A";
addMetadata("site", siteMetadata);
addMetadata("gitCommit", gitCommit);
});
api.loadSource((actions) => {
const collection = actions.addCollection("Skill");
const technologies = skills.technologies.slice().reverse();
technologies.forEach((skill) => {
collection.addNode({
...skill,
id: slugify(skill.name),
});
});
});
api.createPages(({ createPage }) => {
// Use the Pages API here: https://gridsome.org/docs/pages-api/
});
};