Skip to content

Commit 11a5564

Browse files
committed
Migration to ESM
1 parent 7332285 commit 11a5564

5 files changed

Lines changed: 33 additions & 36 deletions

File tree

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function eleventyComputedPermalink() {
1+
export function eleventyComputedPermalink() {
22
// When using `addGlobalData` and you *want* to return a function, you must nest functions like this.
33
// `addGlobalData` acts like a global data file and runs the top level function it receives.
44
return (data) => {
@@ -9,9 +9,9 @@ function eleventyComputedPermalink() {
99

1010
return data.permalink;
1111
}
12-
};
12+
}
1313

14-
function eleventyComputedExcludeFromCollections() {
14+
export function eleventyComputedExcludeFromCollections() {
1515
// When using `addGlobalData` and you *want* to return a function, you must nest functions like this.
1616
// `addGlobalData` acts like a global data file and runs the top level function it receives.
1717
return (data) => {
@@ -22,12 +22,9 @@ function eleventyComputedExcludeFromCollections() {
2222

2323
return data.eleventyExcludeFromCollections;
2424
}
25-
};
26-
27-
module.exports.eleventyComputedPermalink = eleventyComputedPermalink;
28-
module.exports.eleventyComputedExcludeFromCollections = eleventyComputedExcludeFromCollections;
25+
}
2926

30-
module.exports = eleventyConfig => {
27+
export default function(eleventyConfig) {
3128
eleventyConfig.addGlobalData("eleventyComputed.permalink", eleventyComputedPermalink);
3229
eleventyConfig.addGlobalData("eleventyComputed.eleventyExcludeFromCollections", eleventyComputedExcludeFromCollections);
3330

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const path = require("path");
2-
const eleventyImage = require("@11ty/eleventy-img");
1+
import path from "node:path";
2+
import eleventyImage from "@11ty/eleventy-img";
33

4-
module.exports = (eleventyConfig) => {
4+
export default function(eleventyConfig) {
55
function relativeToInputPath(inputPath, relativeFilePath) {
66
let split = inputPath.split("/");
77
split.pop();
@@ -71,4 +71,4 @@ module.exports = (eleventyConfig) => {
7171
return metadata.jpeg[0].url;
7272
}
7373
);
74-
};
74+
}
Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
const { DateTime } = require("luxon");
2-
const minifyXML = require("minify-xml");
3-
const markdownIt = require("markdown-it");
4-
const markdownItMathjax = require("markdown-it-mathjax3");
5-
const markdownItAnchor = require("markdown-it-anchor");
6-
const yaml = require("js-yaml");
7-
8-
const pluginRss = require("@11ty/eleventy-plugin-rss");
9-
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
10-
const pluginBundle = require("@11ty/eleventy-plugin-bundle");
11-
const pluginNavigation = require("@11ty/eleventy-navigation");
12-
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");
13-
14-
const pluginDrafts = require("./eleventy.config.drafts.js");
15-
const pluginImages = require("./eleventy.config.images.js");
1+
import { DateTime } from "luxon";
2+
import minifyXML from "minify-xml";
3+
import markdownIt from "markdown-it";
4+
import markdownItMathjax from "markdown-it-mathjax3";
5+
import markdownItAnchor from "markdown-it-anchor";
6+
import yaml from "js-yaml";
7+
8+
import pluginRss from "@11ty/eleventy-plugin-rss";
9+
import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
10+
import pluginNavigation from "@11ty/eleventy-navigation";
11+
import { EleventyHtmlBasePlugin } from "@11ty/eleventy";
12+
13+
import pluginDrafts from "./eleventy.config.drafts.mjs";
14+
import pluginImages from "./eleventy.config.images.mjs";
1615

1716
const addTargetBlankToExternalLinks = (md) => {
1817
const defaultRender =
@@ -40,7 +39,7 @@ const md = markdownIt({
4039
typographer: true,
4140
}).use(addTargetBlankToExternalLinks);
4241

43-
module.exports = function (eleventyConfig) {
42+
export default function (eleventyConfig) {
4443
eleventyConfig.setServerOptions({
4544
showAllHosts: true,
4645
});
@@ -69,7 +68,9 @@ module.exports = function (eleventyConfig) {
6968
});
7069
eleventyConfig.addPlugin(pluginNavigation);
7170
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
72-
eleventyConfig.addPlugin(pluginBundle);
71+
72+
eleventyConfig.addBundle("css");
73+
eleventyConfig.addBundle("js");
7374

7475
eleventyConfig.addDataExtension("yml", (contents) => yaml.load(contents));
7576

@@ -200,4 +201,4 @@ module.exports = function (eleventyConfig) {
200201
// folder name and does **not** affect where things go in the output folder.
201202
pathPrefix: "/",
202203
};
203-
};
204+
}

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"@11ty/eleventy": "^3.1.5",
2424
"@11ty/eleventy-img": "^6.0.4",
2525
"@11ty/eleventy-navigation": "^1.0.5",
26-
"@11ty/eleventy-plugin-bundle": "^3.0.7",
2726
"@11ty/eleventy-plugin-rss": "^1.2.0",
2827
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.2",
2928
"@11ty/is-land": "^4.0.0",

0 commit comments

Comments
 (0)