-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.js
32 lines (29 loc) · 1.11 KB
/
gatsby-node.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
const path = require('path')
const fs = require('fs');
const wiki = 'jonrobson.me.uk.wiki';
// Generate all family tree pages from wiki equivalents
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions
return new Promise((resolve, reject) => {
fs.readdir(wiki, function(err, filenames) {
filenames.forEach((filename) => {
const uripath = filename === 'Home.md' ?
'index.html' :
filename.replace('_', '/').replace('.md', '');
const content = fs.readFileSync(`${wiki}/${filename}`, 'utf-8' );
// @todo uppercase?
const title = filename === 'Home.md' ? false :
`The ${uripath.split('/')[0]}'s`;
createPage({
path: `/family/${uripath}`,
component: path.resolve(`./src/templates/tree.jsx`),
context: {
title: title,
body: content
}
} );
} );
resolve();
} );
});
};