Replace Nunjucks with Liquid #2

Merged
sthag merged 20 commits from development into main 2026-03-15 09:40:22 +01:00
2 changed files with 16 additions and 3 deletions
Showing only changes of commit d3ab17d5a1 - Show all commits

View file

@ -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/'
};
}

View file

@ -1,5 +1,5 @@
---
permalink: "/"
permalink: "{{ hippie.demoPath }}"
title: Index
---
{% assign pageId = page.fileSlug -%}