From c5ecdde630ed1af040bba73c06b4ce1c90e6b4d4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 2 Aug 2026 01:40:59 +0200 Subject: [PATCH] Convert config to ESM --- .eleventy.js => eleventy.config.js | 6 +++--- package.json | 1 + src/_data/i18n.js | 11 +++++++---- 3 files changed, 11 insertions(+), 7 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 56ed6e7..f2d014a 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "octoturge-site", "version": "1.0.0", "private": true, + "type": "module", "scripts": { "build:11ty": "eleventy", "build:css": "tailwindcss -i ./src/assets/css/tailwind.css -o ./dist/assets/css/style.css --minify", 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; -}; +}