migrate to Eleventy v3 and ESM, upgrade dependencies
Some checks failed
publish / publish (push) Failing after 4m13s

This commit is contained in:
Lyn Fugmann 2024-10-06 17:58:35 +02:00
parent 84e3af4205
commit f10dcd9df8
5 changed files with 988 additions and 1035 deletions

View file

@ -1,19 +1,20 @@
const { EleventyHtmlBasePlugin, EleventyI18nPlugin } = require("@11ty/eleventy");
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
const faviconsPlugin = require("eleventy-plugin-gen-favicons");
const bundlerPlugin = require("@11ty/eleventy-plugin-bundle");
const pluginIcons = require('eleventy-plugin-icons');
const Image = require("@11ty/eleventy-img");
const yaml = require("js-yaml");
const fs = require('fs');
import { EleventyHtmlBasePlugin, EleventyI18nPlugin } from "@11ty/eleventy";
import eleventyNavigationPlugin from "@11ty/eleventy-navigation";
import Image from "@11ty/eleventy-img";
module.exports = function(eleventyConfig) {
import faviconsPlugin from "eleventy-plugin-gen-favicons";
import pluginIcons from 'eleventy-plugin-icons';
import SvgTextToPath from 'svg-text-to-path';
import markdownIt from 'markdown-it';
import yaml from "js-yaml";
import fs from 'fs';
export default async function(eleventyConfig) {
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPlugin(EleventyI18nPlugin, {
defaultLanguage: "de",
});
eleventyConfig.addPlugin(bundlerPlugin);
let fontawesomePath = "node_modules/@fortawesome/fontawesome-free/svgs";
eleventyConfig.addPlugin(pluginIcons, {
sources: [
@ -27,15 +28,20 @@ module.exports = function(eleventyConfig) {
});
eleventyConfig.addPlugin(faviconsPlugin, {});
eleventyConfig.addBundle("css", {
toFileDirectory: "bundle",
});
eleventyConfig.addBundle("js");
// override icon shortcode to make the SVGs accessible
eleventyConfig.addAsyncShortcode("icon", async function(input, attrs) {
let out;
if (!attrs || !("title" in attrs)) {
out = await eleventyConfig.nunjucksAsyncShortcodes.rawIcon(input, attrs);
out = await eleventyConfig.universal.shortcodes.rawIcon(input, attrs);
} else {
const { title, ...newAttrs } = attrs;
newAttrs.role = "img";
const svgStr = await eleventyConfig.nunjucksAsyncShortcodes.rawIcon(input, newAttrs);
const svgStr = await eleventyConfig.universal.shortcodes.rawIcon(input, newAttrs);
const match = svgStr.match(/(<svg.*?>)(.*$)/s);
out = match[1] + "<title>" + title + "</title>" + match[2];
}
@ -71,9 +77,7 @@ module.exports = function(eleventyConfig) {
svg = svg.replaceAll("{{ese.color}}", data.ese.color);
// render text to path
// TODO replace with ESM import once we switch to Eleventy v3
const Session = (await import('svg-text-to-path')).default;
let session = new Session(svg, {
let session = new SvgTextToPath(svg, {
fonts: {
"Aileron Thin": [{
wght: 400,
@ -123,8 +127,7 @@ module.exports = function(eleventyConfig) {
};
eleventyConfig.addAsyncFilter('mdInline', async function(value) {
// TODO replace with ESM import once we switch to Eleventy v3
const md = (await import('markdown-it/index.mjs')).default();
const md = markdownIt();
// customize link rendering
md.renderer.rules.link_open = md_link_open;