feat: prototype custom pages site generation

This commit is contained in:
endiliey 2018-08-08 01:33:25 +08:00
parent cf08a20737
commit bc7b2835b0
8 changed files with 78 additions and 9 deletions

23
lib/load/pages.js Normal file
View file

@ -0,0 +1,23 @@
const fs = require('fs-extra');
const path = require('path');
const globby = require('globby');
const {encodePath, fileToPath} = require('./utils');
async function loadPages(pagesDir) {
const pagesFiles = await globby(['**/*.js'], {
cwd: pagesDir
});
const pagesData = await Promise.all(
pagesFiles.map(async source => {
const filepath = path.resolve(pagesDir, source);
return {
path: encodePath(fileToPath(source)),
source
};
})
);
return pagesData;
}
module.exports = loadPages;