-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathgridsome.server.js
More file actions
32 lines (29 loc) · 949 Bytes
/
gridsome.server.js
File metadata and controls
32 lines (29 loc) · 949 Bytes
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
const cw = require('capture-website')
const crypto = require('crypto')
const projects = require('./projects.json')
module.exports = function(api) {
api.loadSource(async (actions) => {
const contentTypeProjects = actions.addCollection('Project')
for (const [index, project] of projects.entries()) {
const randomId = crypto.randomBytes(12).toString('hex')
try {
await cw.file(project.url, `./src/assets/img/${randomId}.png`, {
scaleFactor: 1,
timeout: 360,
})
project.image = `${randomId}.png`
contentTypeProjects.addNode({
id: index,
name: project.name,
image: project.image,
description: project.description,
url: project.url,
source: project.source,
tags: project.tags,
})
} catch (err) {
console.error(`Capture website error: project ${project.name}`, err)
}
}
})
}