-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgridsome.server.js
46 lines (39 loc) · 1.23 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
const path = require('path')
const fs = require('fs-extra')
const execa = require('execa')
const yaml = require('js-yaml')
const Prism = require('prismjs')
// highlight page-query and static-query in html
Prism.languages.html.graphql = {
pattern: /(<(page|static)-query[\s\S]*?>)[\s\S]*?(?=<\/(page|static)-query>)/i,
inside: Prism.languages.graphql,
lookbehind: true,
greedy: true
}
module.exports = function (api) {
api.loadSource(async ({ addMetadata, addCollection }) => {
let gridsomeVersion = ''
try {
const { stdout } = await execa('npm', ['show', 'gridsome', 'version'])
gridsomeVersion = stdout
} catch (err) {
console.warn('Failed to get gridsome version from npm.')
}
addMetadata('gridsomeVersion', gridsomeVersion)
// contributors
const authorsPath = path.join(__dirname, 'contributors/contributors.yaml')
const authorsRaw = await fs.readFile(authorsPath, 'utf8')
const authorsJson = yaml.safeLoad(authorsRaw)
const authors = addCollection('Contributor')
authorsJson.forEach(({ id, name: title, ...fields }) => {
authors.addNode({
id,
title,
internal: {
origin: authorsPath
},
...fields
})
})
})
}