Replace Nunjucks with Liquid #2
2 changed files with 16 additions and 3 deletions
17
.eleventy.js
17
.eleventy.js
|
|
@ -1,8 +1,19 @@
|
|||
/* jshint strict: false */
|
||||
|
||||
import fs from 'fs/promises';
|
||||
import {HtmlBasePlugin} from "@11ty/eleventy";
|
||||
import pluginWebc from "@11ty/eleventy-plugin-webc";
|
||||
|
||||
async function hasFiles(dirPath) {
|
||||
try {
|
||||
const entries = await fs.readdir(dirPath, {withFileTypes: true});
|
||||
return entries.some(entry => entry.isFile());
|
||||
} catch (err) {
|
||||
console.error('Error reading directory:', err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
export default async function (eleventyConfig) {
|
||||
eleventyConfig.addPlugin(HtmlBasePlugin);
|
||||
|
|
@ -19,6 +30,9 @@ export default async function (eleventyConfig) {
|
|||
eleventyConfig.addGlobalData('permalink', () => {
|
||||
return (data) => `${data.page.filePathStem}.${data.page.outputFileExtension}`;
|
||||
});
|
||||
|
||||
const demoPath = await hasFiles('source/screens') ? '/demo/' : '/';
|
||||
|
||||
eleventyConfig.addGlobalData('hippie', {
|
||||
brand: 'hippie',
|
||||
titlePrefix: '',
|
||||
|
|
@ -30,6 +44,7 @@ export default async function (eleventyConfig) {
|
|||
mail: 'name@domain.tld',
|
||||
domain: 'https://domain.tld'
|
||||
},
|
||||
demoPath: demoPath,
|
||||
debugMode: true,
|
||||
legacyMode: false
|
||||
});
|
||||
|
|
@ -85,7 +100,6 @@ export default async function (eleventyConfig) {
|
|||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
`;
|
||||
let output = '';
|
||||
|
||||
|
|
@ -124,6 +138,5 @@ export default async function (eleventyConfig) {
|
|||
data: '../data'
|
||||
},
|
||||
templateFormats: ['html', 'liquid', 'md']
|
||||
// pathPrefix: './demo/'
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
permalink: "/"
|
||||
permalink: "{{ hippie.demoPath }}"
|
||||
title: Index
|
||||
---
|
||||
{% assign pageId = page.fileSlug -%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue