Various fixes

This commit is contained in:
2023-03-06 00:56:03 -05:00
parent 2abfed0783
commit 2c96be92e5
31 changed files with 1313 additions and 717 deletions

View File

@@ -7,17 +7,17 @@ module.exports = async (config) => {
ejs = require("ejs"),
frontMatter = require("front-matter"),
glob = require("glob"),
hljs = require("highlight.js"),
dictionary = {
"/astral/vessels.html": ["vessel", "vessels"],
"/campaign/timeline.html": ["last session"],
"https://oldschoolessentials.necroticgnome.com/srd/index.php/Structures":
["stronghold"],
"/astral/timeline.html": ["CAC", "BAC", "Common Astral Calendar"],
"/astral/adventuring.html#portals": ["portal", "portals"],
"/astral/adventuring.html#outposts": ["outpost", "outposts"],
"/astral/adventuring.html#fragments": ["island", "islands"],
},
md = require("markdown-it")({
highlight: (str, lang) => {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(str, { language: lang }).value;
} catch (__) {}
}
return ""; // use external default escaping
},
html: true,
linkify: true,
typographer: true,
@@ -36,8 +36,12 @@ module.exports = async (config) => {
headerless: true,
multibody: true,
aotolabel: true,
})
.use(require("markdown-it-emoji"))
.use(require("markdown-it-mark"))
.use(require("markdown-it-auto-crosslinker"), {
dictionary,
}),
emoji = require("markdown-it-emoji"),
// { readJsonIfExists } = require("./utils"),
{ build, isRebuild, logFunction: log = () => {} } = config || {},
{ outputPath, journalsPerPage = 5, srcPath } = build,
@@ -201,8 +205,7 @@ module.exports = async (config) => {
}
};
md.use(emoji);
// md.use(emoji);
log(`${isRebuild ? "Reb" : "B"}uilding...`);
// clear destination folder
@@ -241,7 +244,8 @@ module.exports = async (config) => {
},
pages = files
.map(({ page }) => ({ ...page }))
.filter(({ is_draft }) => !is_draft)
.filter(({ is_draft = false }) => !is_draft)
.filter(({ status }) => status !== "draft")
.sort(sortByPubDate),
tagCloud = pages.reduce((acc, curr) => {
const { tags } = curr;

View File

@@ -1,26 +1,27 @@
module.exports = async (config) => {
let isReady = false;
const
http = require('http'),
let isReady = false;
const http = require("http"),
address = require("network-address"),
handler = require("serve-handler"),
build = require("./build"),
{
build: buildOpts,
logFunction: log = () => {},
serve: serveOpts,
} = config || {},
{ outputPath, srcPath } = buildOpts || {},
{ port = 5000 } = serveOpts || {},
server = http.createServer((request, response) => {
// You pass two more arguments for config and middleware
// More details here: https://github.com/vercel/serve-handler#options
return handler(request, response, { public: outputPath });
});
address = require('network-address'),
handler = require('serve-handler'),
await build(config);
build = require('./build'),
{ build: buildOpts, logFunction: log = () => {}, serve: serveOpts } = config || {},
{ outputPath, srcPath } = buildOpts || {},
{ port = 5000 } = serveOpts || {},
server = http.createServer((request, response) => {
// You pass two more arguments for config and middleware
// More details here: https://github.com/vercel/serve-handler#options
return handler(request, response, { public: outputPath });
});
await build(config);
server.listen(port, async () => {
log(`Running at http://${address()}:${port} / http://localhost:${port}`);
});
};
server.listen(port, async () => {
log(
`Running at http://${address()}:${port} / http://localhost:${port}`
);
});
};