From c43e553fae904cb99f957db8649d7eab54fb96d0 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 2 Aug 2026 01:41:08 +0200 Subject: [PATCH] Convert config to ESM --- .eleventy.js => eleventy.config.js | 6 +++--- package.json | 3 ++- src/_data/i18n.js | 11 +++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) rename .eleventy.js => eleventy.config.js (86%) diff --git a/.eleventy.js b/eleventy.config.js similarity index 86% rename from .eleventy.js rename to eleventy.config.js index e5dc39f..4ebab28 100644 --- a/.eleventy.js +++ b/eleventy.config.js @@ -1,6 +1,6 @@ -const pug = require("pug"); +import pug from "pug"; -module.exports = function (eleventyConfig) { +export default function (eleventyConfig) { eleventyConfig.addPassthroughCopy("src/assets/img"); eleventyConfig.addExtension("pug", { @@ -21,4 +21,4 @@ module.exports = function (eleventyConfig) { htmlTemplateEngine: "pug", markdownTemplateEngine: "pug", }; -}; +} diff --git a/package.json b/package.json index 25f9c93..d1eb239 100644 --- a/package.json +++ b/package.json @@ -12,5 +12,6 @@ "@11ty/eleventy": "^3.0.0", "pug": "^3.0.3", "tailwindcss": "^3.4.10" - } + }, + "type": "module" } diff --git a/src/_data/i18n.js b/src/_data/i18n.js index 92535a7..0f391a8 100644 --- a/src/_data/i18n.js +++ b/src/_data/i18n.js @@ -1,7 +1,10 @@ -const fs = require("fs"); -const path = require("path"); +import fs from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; -module.exports = function () { +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +export default function () { const localesDir = path.join(__dirname, "..", "locales"); const dict = {}; for (const file of fs.readdirSync(localesDir)) { @@ -10,4 +13,4 @@ module.exports = function () { dict[locale] = JSON.parse(fs.readFileSync(path.join(localesDir, file), "utf8")); } return dict; -}; +}