forked from sveltejs/community-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssg.config.js
36 lines (31 loc) · 1.06 KB
/
ssg.config.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
const fs = require('fs');
const path = require('path');
const yaml = require('@ssgjs/source-yaml').default;
exports.plugins = {
yamlFiles: yaml({ dirPath: 'data' })
};
let eventsData = null;
exports.createIndex = async (mainIndex = {}) => {
// do expensive initial fetches and cache them in .ssg/data.json
// console.log({ mainIndex: Object.keys(mainIndex.data) })
mainIndex.events = mainIndex.yamlFiles['data-events-yml'].data.EventsList;
mainIndex.resources = mainIndex.yamlFiles['data-resources-yml'].data;
mainIndex.code = mainIndex.yamlFiles['data-code-yml'].data;
mainIndex.showcase = mainIndex.yamlFiles['data-showcase-yml'].data;
return mainIndex;
};
// optional. called repeatedly, can be expensive
exports.getDataSlice = async (key, uid) => {
// we dont really use the key here
if (key === 'events') {
// uid == the event's ID
return eventsData[uid];
} else {
throw new Error('invalid key ' + key);
}
};
// optional lifecycle hook
exports.postExport = async mainIndex => {
// eg for RSS
// console.log('postExport', mainIndex)
};