/* jshint strict: false */ import fs from "node:fs"; import path from "node:path"; 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); eleventyConfig.addPlugin(pluginWebc); eleventyConfig.setLiquidOptions({ root: [ eleventyConfig.directories.includes, // eleventyConfig.directories.input + '../_includes', fs.realpathSync(path.resolve('./node_modules/hippie/source/view/_includes')) ] }); eleventyConfig.addGlobalData('permalink', () => { return (data) => `${data.page.filePathStem}.${data.page.outputFileExtension}`; }); // TODO: Demo entfernen const permalinkPath = await hasFiles('source/view') ? '/demo/' : '/'; eleventyConfig.addGlobalData('hippie', { brand: 'hippie', titlePrefix: '', titlePostfix: ' - HIPPIE', placeholders: { name: 'Vorname Nachname', address: 'Straße Nr., PLZ Ort', phone: '+49 (0)101 1337 48', mail: 'name@domain.tld', domain: 'https://domain.tld' }, permalink: permalinkPath, debugMode: true, legacyMode: false }); eleventyConfig.addShortcode('text', function (text, attrId, attrClass) { return `${text}`; }); eleventyConfig.addShortcode('link', function (target, text, attrId, attrClass) { if (!text || text === '') { text = target; } if (target.indexOf('@') !== -1) { target = 'mailto:' + target; } return `${text}`; }); eleventyConfig.addPairedShortcode('brand', function (content, attrClass = 'brand', direction = 'first') { const logo = ` `; let output = ''; switch (direction) { case 'first': output = logo + `${content}`; break; case 'last': output = `${content}` + logo; break; } return `
` + output + `
`; }); eleventyConfig.addPassthroughCopy({ 'source/art/images': 'art' }); eleventyConfig.addPassthroughCopy({ 'source/art/favicons/**/*.+(ico|png|svg)': '.' }); eleventyConfig.addPassthroughCopy({ 'source/code/**/*.js': 'js' }); eleventyConfig.addPassthroughCopy({ 'source/data/**/*.json': 'json' }); eleventyConfig.addPassthroughCopy('vendor'); eleventyConfig.addPassthroughCopy({ 'node_modules/bootstrap-icons': 'vendor/bootstrap-icons' }); eleventyConfig.addPassthroughCopy({ 'node_modules/jquery/dist/jquery.min.js': 'vendor/jquery.min.js', 'node_modules/jquery/dist/jquery.min.map': 'vendor/jquery.min.map' }); eleventyConfig.addPassthroughCopy({ 'node_modules/hippie-script/index.js': 'vendor/hippie-script.js' }); eleventyConfig.addWatchTarget('./source/style/'); } // noinspection JSUnusedGlobalSymbols export const config = { dir: { input: 'source/view', output: 'build' }, templateFormats: ['html', 'liquid', 'md', 'njk'] };