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

@ -8,6 +8,7 @@ eleventyComputed:
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="{{ eleventy.generator }}">
<title>{% if title %}{{ title }} | {% endif %}ESE {{ ese.year }}</title>
<link rel="stylesheet" href="{% getBundleFileUrl "css" %}">
<link rel="stylesheet" href="/aileron.lite.min.css">

View file

@ -1,6 +1,6 @@
const { ICalCalendar, ICalCalendarMethod } = require('ical-generator')
import { ICalCalendar, ICalCalendarMethod } from 'ical-generator';
module.exports = class ProgramIcal {
export default class ProgramIcal {
getDate(date, time) {
const d = new Date(date);
const [ hours, mins ] = time.split(":");

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;

1975
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -3,6 +3,7 @@
"version": "2.0.0",
"description": "This is the WIP rewrite of the ESE website.",
"main": "index.js",
"type": "module",
"scripts": {
"prebuild": "npx @11ty/eleventy --formats=logo.svg",
"build": "npx @11ty/eleventy --formats=md,njk",
@ -12,10 +13,9 @@
"author": "FSR Informatik TU Dresden",
"license": "MIT",
"devDependencies": {
"@11ty/eleventy": "^2.0.1",
"@11ty/eleventy-img": "^4.0.2",
"@11ty/eleventy": "^3.0.0",
"@11ty/eleventy-img": "^5.0.0",
"@11ty/eleventy-navigation": "^0.3.5",
"@11ty/eleventy-plugin-bundle": "^1.0.5",
"@fortawesome/fontawesome-free": "^6.6.0",
"eleventy-plugin-gen-favicons": "^1.1.3",
"eleventy-plugin-icons": "^4.5.1",