Get includes working relatively.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<meta name="description" content="{{ page.description | join(' ') }}"/>
|
||||
<link rel="stylesheet" href="/main.css"/>
|
||||
<link rel="stylesheet" href="/public/styles/highlightjs-theme.css"/>
|
||||
{{ googleFonts('https://fonts.googleapis.com/css2?family=Fredoka:wght@300;400;500&display=swap') }}
|
||||
{{ 'https://fonts.googleapis.com/css2?family=Fredoka:wght@300;400;500&display=swap' | googleFonts }}
|
||||
</head>
|
||||
<body class="text-base pt-16">
|
||||
{{ Node('Navbar', {}, { headings: page.headings, url: url }) }}
|
||||
|
||||
@@ -8,7 +8,9 @@ import featherIcons from './util/feather-icons.js'
|
||||
|
||||
const pages = {
|
||||
'/': './pages/index.tce',
|
||||
'/about/': './pages/about.tce'
|
||||
'/about/': './pages/about.tce',
|
||||
'/docs/javascript/': './pages/docs/javascript.tce',
|
||||
'/docs/c/': './pages/docs/c.tce'
|
||||
}
|
||||
|
||||
async function render() {
|
||||
@@ -17,7 +19,14 @@ async function render() {
|
||||
for (const [urlPath, filePath] of Object.entries(pages)) {
|
||||
const env = nunjucks.configure('renderer/', { autoescape: false })
|
||||
|
||||
env.addGlobal('googleFonts', googleFonts)
|
||||
env.addFilter('googleFonts', async (val, cb) => {
|
||||
try {
|
||||
cb(null, await googleFonts(val))
|
||||
} catch (e) {
|
||||
cb(e)
|
||||
}
|
||||
}, true)
|
||||
|
||||
env.addGlobal('featherIcons', featherIcons)
|
||||
|
||||
HighlightJS.registerLanguage('terrace', () => ({
|
||||
@@ -36,7 +45,13 @@ async function render() {
|
||||
})
|
||||
|
||||
const page = await readPage(filePath)
|
||||
const result = env.render('layout.njk', { page, url: urlPath, file: filePath })
|
||||
|
||||
const result = await new Promise((resolve, reject) => {
|
||||
env.render('layout.njk', { page, url: urlPath, file: filePath }, (err, res) => {
|
||||
if (err) return reject(err)
|
||||
resolve(res)
|
||||
})
|
||||
})
|
||||
|
||||
await fs.mkdir(path.join('dist', urlPath), { recursive: true })
|
||||
await fs.writeFile(path.join('dist', urlPath, 'index.html'), result)
|
||||
|
||||
Reference in New Issue
Block a user