mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 07:16:17 +00:00
pageWriter now writes posts first so that the post content is available for pages.
This commit is contained in:
parent
ae0ed2f18f
commit
32382ae59b
@ -127,7 +127,8 @@ module.exports = exports = async function (prod) {
|
||||
},
|
||||
[ENGINE.MARKDOWN]: (source, env) => shrink(pageTemplate({ ...env, contents: markdown('full', source, env) })),
|
||||
[ENGINE.OTHER]: (source) => shrink(source),
|
||||
PREVIEW: (source, env) => markdown('preview', source, env),
|
||||
MARKDOWN_CONTENT: (source, env) => markdown('full', source, env),
|
||||
MARKDOWN_PREVIEW: (source, env) => markdown('preview', source, env),
|
||||
};
|
||||
|
||||
return result;
|
||||
|
@ -59,7 +59,7 @@ exports.everything = function (prod = false) {
|
||||
await evaluate(tasks.flat(), cache);
|
||||
await cache.save();
|
||||
|
||||
await pageWriter([ ...pages, ...posts ], prod);
|
||||
await pageWriter(pages, posts, prod);
|
||||
}
|
||||
|
||||
fn.displayName = prod ? 'buildForProd' : 'build';
|
||||
|
@ -2,13 +2,17 @@ const path = require('path');
|
||||
const Promise = require('bluebird');
|
||||
const fs = require('fs-extra');
|
||||
const getEngines = require('./engines');
|
||||
const { resolve, ROOT } = require('./resolve');
|
||||
const { resolve, ROOT, ENGINE } = require('./resolve');
|
||||
const { siteInfo } = require(resolve('package.json'));
|
||||
|
||||
module.exports = exports = async function writePageContent (pages, prod) {
|
||||
module.exports = exports = async function writePageContent (pages, posts, prod) {
|
||||
const engines = await getEngines(prod);
|
||||
await processPages(engines, posts, null, prod);
|
||||
await processPages(engines, pages, posts, prod);
|
||||
};
|
||||
|
||||
await Promise.map(pages, async (page) => {
|
||||
function processPages (engines, pages, posts, prod) {
|
||||
return Promise.map(pages, async (page) => {
|
||||
// page = new Page(page);
|
||||
|
||||
var data = {
|
||||
@ -27,11 +31,10 @@ module.exports = exports = async function writePageContent (pages, prod) {
|
||||
root: ROOT,
|
||||
basename: page.basename,
|
||||
},
|
||||
pages,
|
||||
posts,
|
||||
};
|
||||
|
||||
const html = String(engines[page.engine](data.source, data));
|
||||
const json = page.json && {
|
||||
const json = {
|
||||
url: page.fullurl,
|
||||
title: page.meta.title,
|
||||
subtitle: page.meta.subtitle,
|
||||
@ -41,16 +44,21 @@ module.exports = exports = async function writePageContent (pages, prod) {
|
||||
dateCreated: page.dateCreated,
|
||||
dateModified: page.dateModified,
|
||||
titlecard: page.titlecard,
|
||||
preview: page.engine === 'md' && String(engines.preview(data.source, data)),
|
||||
};
|
||||
|
||||
const html = String(engines[page.engine](data.source, data));
|
||||
if (page.engine === ENGINE.MARKDOWN) {
|
||||
json.preview = String(engines.MARKDOWN_PREVIEW(data.source, data));
|
||||
page.content = String(engines.MARKDOWN_CONTENT(data.source, data));
|
||||
}
|
||||
|
||||
const output = resolve('dist', page.out);
|
||||
await fs.ensureDir(path.dirname(output));
|
||||
await Promise.all([
|
||||
fs.writeFile(output, Buffer.from(html)),
|
||||
json && fs.writeFile(resolve('dist', page.json), Buffer.from(
|
||||
page.json && fs.writeFile(resolve('dist', page.json), Buffer.from(
|
||||
prod ? JSON.stringify(json) : JSON.stringify(json, null, 2),
|
||||
)),
|
||||
]);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user