From c09a9704a4ffdb354747a6173611b8297c7be80c Mon Sep 17 00:00:00 2001 From: sthag Date: Sat, 11 Apr 2026 09:21:31 +0200 Subject: [PATCH] init: HIPPIE bus The package provides template configuration and npm scripts for HIPPIE. --- .eleventy.js | 142 +++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 2 + bus/package.json | 21 +++++++ package.json | 27 +++++++++ 4 files changed, 192 insertions(+) create mode 100644 .eleventy.js create mode 100644 .gitignore create mode 100644 bus/package.json create mode 100644 package.json diff --git a/.eleventy.js b/.eleventy.js new file mode 100644 index 0000000..a29e297 --- /dev/null +++ b/.eleventy.js @@ -0,0 +1,142 @@ +/* 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); + eleventyConfig.addPlugin(pluginWebc); + + eleventyConfig.setLiquidOptions({ + // greedy: false, + // trimOutputLeft: true, + // trimOutputRight: true, + // trimTagLeft: true, + // trimTagRight : true, + }); + + 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'] +}; \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1fe1b00 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +node_modules/ diff --git a/bus/package.json b/bus/package.json new file mode 100644 index 0000000..fc22b60 --- /dev/null +++ b/bus/package.json @@ -0,0 +1,21 @@ +{ + "name": "hippie-bus-bus", + "private": true, + "scripts": { + "hello": "echo -n \"This is \" && node -p \"process.env.npm_package_name\" | tr '[:lower:]' '[:upper:]'", + "test": "echo \"Error: no test specified\" && exit 1", + "clean": "npm run clean:build & npm run clean:deploy & npm run clean:report & npm run clean:test", + "clean:build": "rm -rf ../build/*", + "clean:deploy": "rm -rf ../deploy/*", + "clean:report": "rm -rf ../report/*", + "clean:test": "rm -rf ../test/*", + "style:compile": "sass ../source/style:build/css --load-path=vendor", + "style:deploy": "sass ../source/style:deploy/css --load-path=vendor", + "style:watch": "sass --watch ../source/style:build/css --load-path=vendor", + "build:new": "npm run clean:build && npx @11ty/eleventy && npm run style:compile", + "build": "npx @11ty/eleventy && npm run style:compile", + "deploy": "npm run clean:deploy && npx @11ty/eleventy --output=deploy --pathprefix=hippie && npm run style:deploy", + "serve": "npm run style:watch & npx @11ty/eleventy --serve", + "debug": "DEBUG=* npx @11ty/eleventy --" + } +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..16e3ae4 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "hippie-bus", + "version": "1.0.0", + "description": "Drive the HIPPIE bus to your wonderland", + "keywords": [ + "hippie", + "workspace", + "build" + ], + "homepage": "https://quelltext.interaktionsweise.de/interaktionsweise/hippie-bus", + "bugs": "https://quelltext.interaktionsweise.de/interaktionsweise/hippie-bus/issues", + "license": "MIT", + "author": "Stephan Hagedorn (https://karte.interaktionsweise.de)", + "repository": { + "type": "git", + "url": "https://quelltext.interaktionsweise.de/interaktionsweise/hippie-bus.git" + }, + "type": "module", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "private": true, + "peerDependencies": { + "@11ty/eleventy": "^3.1.2" + } +} \ No newline at end of file