From 12ec4f2b1656a5d154073731503aa0e37f8d36ea Mon Sep 17 00:00:00 2001 From: Cassie Jones Date: Sat, 5 Oct 2024 11:39:18 -0700 Subject: [PATCH] Move to an ES module for config --- .eleventy.js => eleventy.config.js | 25 +++++++++++++------------ package.json | 3 ++- 2 files changed, 15 insertions(+), 13 deletions(-) rename .eleventy.js => eleventy.config.js (88%) diff --git a/.eleventy.js b/eleventy.config.js similarity index 88% rename from .eleventy.js rename to eleventy.config.js index c8b4207..bf25e32 100644 --- a/.eleventy.js +++ b/eleventy.config.js @@ -1,11 +1,14 @@ -// @TODO: Update to the new virtual template setup? -const pluginRss = require("@11ty/eleventy-plugin-rss"); -const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); -const Nunjucks = require("nunjucks"); -const dateFilter = require("nunjucks-date-filter"); -const uslug = require("uslug"); -const anchor = require("markdown-it-anchor"); -const md = require("markdown-it")({ +import pluginRss from "@11ty/eleventy-plugin-rss"; +import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight"; +import dateFilter from "nunjucks-date-filter"; +import uslug from "uslug"; +import anchor from "markdown-it-anchor"; +import markdownIt from "markdown-it"; +import CleanCSS from "clean-css"; +import htmlMinifier from "html-minifier-terser"; +import util from "util"; + +const md = markdownIt({ html: true, typographer: true, }).use(anchor, { @@ -14,12 +17,10 @@ const md = require("markdown-it")({ permalinkBefore: true, permalinkClass: "header-anchor c-sun dec-none", }); -const CleanCSS = require("clean-css"); -const htmlMinifier = require("html-minifier-terser"); -const util = require("util"); -module.exports = (eleventyConfig) => { +export default async function (eleventyConfig) { eleventyConfig.addNunjucksFilter('date', dateFilter); + // @TODO: Update to the new virtual template setup? eleventyConfig.addPlugin(pluginRss); eleventyConfig.addPlugin(pluginSyntaxHighlight); diff --git a/package.json b/package.json index 59c2136..00eb0f3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "blog", "version": "1.0.0", "description": "My blog", - "main": ".eleventy.js", + "main": "eleventy.config.js", + "type": "module", "devDependencies": { "@11ty/eleventy": "^3.0.0", "@11ty/eleventy-plugin-rss": "^2.0.0", -- 2.47.0