Page generation now gets data passed to it from index
This commit is contained in:
parent
84268df649
commit
1f6be804b7
2 changed files with 14 additions and 8 deletions
14
index.js
14
index.js
|
@ -1,6 +1,16 @@
|
|||
const { getPinnedRepoJSONs, getStaticPageJSONs } = require('./src/discoverJSONData');
|
||||
const { generateStaticPages } = require('./src/generateHTMLPages');
|
||||
const copyStaticAssets = require('./src/copyStaticAssets');
|
||||
|
||||
generateStaticPages().then(() => console.log('✓ Generated html pages'));
|
||||
copyStaticAssets().then(() => console.log('✓ Copied static assets'));
|
||||
(async () => {
|
||||
let repoJSONs = await getPinnedRepoJSONs();
|
||||
let staticJSONs = await getStaticPageJSONs();
|
||||
await generateStaticPages(repoJSONs.concat(staticJSONs));
|
||||
console.log('✓ Generated html pages');
|
||||
})();
|
||||
|
||||
(async () => {
|
||||
await copyStaticAssets();
|
||||
console.log('✓ Copied static assets');
|
||||
})();
|
||||
|
||||
|
|
|
@ -2,15 +2,11 @@ const { join } = require('path');
|
|||
const { outputFile } = require('fs-extra');
|
||||
const marked = require('marked');
|
||||
const getTemplate = require('./template');
|
||||
const { getPinnedRepoJSONs, getStaticPageJSONs } = require('./discoverJSONData');
|
||||
|
||||
const distPath = './dist';
|
||||
|
||||
const generateStaticPages = async () => {
|
||||
const generateStaticPages = async jsonData => {
|
||||
const interiorTemplate = await getTemplate('interior');
|
||||
let repoJSONs = await getPinnedRepoJSONs();
|
||||
let staticJSONs = await getStaticPageJSONs();
|
||||
let combinedJSONs = repoJSONs.concat(staticJSONs);
|
||||
const saveAsInteriorHTML = async json => {
|
||||
let fileName = json.name.replace(/[^a-zA-Z\d:]/g, '').toLowerCase();
|
||||
if (json.readme && json.readme.text) {
|
||||
|
@ -20,7 +16,7 @@ const generateStaticPages = async () => {
|
|||
}
|
||||
|
||||
try {
|
||||
return await Promise.all(combinedJSONs.map(saveAsInteriorHTML));
|
||||
return await Promise.all(jsonData.map(saveAsInteriorHTML));
|
||||
} catch (error) {
|
||||
console.error('Error while writing html files', error);
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue