mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2025-04-11 18:12:01 +00:00
Create support for languages, then reformat user, home, and post pages to use it, and create en and en-us language files.
29 lines
885 B
JavaScript
29 lines
885 B
JavaScript
const fs = require("fs").promises
|
|
const pj = require("path").join
|
|
|
|
;(async () => {
|
|
const contents = await fs.readFile(pj(__dirname, "base.txt"), "utf8")
|
|
const lines = contents.split("\n")
|
|
let template = await fs.readFile(pj(__dirname, "base.template.js"), "utf8")
|
|
|
|
template = template
|
|
.replace("// This file is a template.", "// This file was automatically generated and its contents will be overwritten later.")
|
|
.replace("// CONTENT", lines
|
|
.filter(l => l && !l.startsWith("#"))
|
|
.map(l => {
|
|
if (l.startsWith("pug_")) {
|
|
return `"${l}": locals => "MISSING TEMPLATE: ${l}"`
|
|
} else if (l.startsWith("fn_")) {
|
|
return `"${l}": () => "MISSING FUNCTION: ${l}"`
|
|
} else {
|
|
return `"${l}": "MISSING STRING: ${l}"`
|
|
}
|
|
})
|
|
.join(",\n\t")
|
|
)
|
|
|
|
await fs.writeFile(pj(__dirname, "../base.js"), template, "utf8")
|
|
|
|
console.log("base.js written.")
|
|
})()
|