|
1 | | -import { EleventyRenderPlugin } from "@11ty/eleventy"; |
2 | | -import markdownIt from "markdown-it"; |
3 | | -import markdownAnchor from "markdown-it-anchor"; |
| 1 | +import { EleventyRenderPlugin, IdAttributePlugin } from "@11ty/eleventy"; |
4 | 2 |
|
5 | 3 | import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight"; |
6 | | -import { eleventyAlembic } from "@openlab/alembic/11ty.js"; |
| 4 | +import eleventyAlembic from "@openlab/alembic/11ty.js"; |
| 5 | +import eleventyNavigation from "@11ty/eleventy-navigation"; |
7 | 6 | import slugify from "slugify"; |
8 | 7 |
|
9 | 8 | import pkg from "./package.json" with { type: "json" }; |
10 | 9 | import site from "./source/_data/site.json" with { type: "json" }; |
11 | 10 |
|
12 | | -// TODO: refactor this out when upgrading to eleventy@2 |
13 | | -const md = markdownIt({ |
14 | | - html: true, |
15 | | -}); |
16 | | -md.use(markdownAnchor, { |
17 | | - slugify: (str) => slugify(str, { lower: true, strict: true }), |
18 | | -}); |
19 | | -md.disable("code"); |
20 | | - |
21 | | -// TODO: add watch/rebuild for src in development mode? |
22 | | - |
23 | | -/** @param {import('@11ty/eleventy/src/UserConfig')} eleventyConfig */ |
| 11 | +/** @param {import('@11ty/eleventy/UserConfig').default} eleventyConfig */ |
24 | 12 | export default function (eleventyConfig) { |
25 | | - eleventyConfig.setLibrary("md", md); |
| 13 | + eleventyConfig.setDataDeepMerge(true); // TODO: remove for eleventy@4 |
26 | 14 |
|
| 15 | + eleventyConfig.addPlugin(IdAttributePlugin); |
27 | 16 | eleventyConfig.addPlugin(EleventyRenderPlugin); |
28 | 17 | eleventyConfig.addPlugin(eleventyAlembic); |
29 | 18 | eleventyConfig.addPlugin(syntaxHighlight); |
| 19 | + eleventyConfig.addPlugin(eleventyNavigation); |
30 | 20 |
|
31 | | - eleventyConfig.addFilter("apiSort", (items) => { |
32 | | - return Array.from(items).sort((a, b) => |
33 | | - b.data.title.localeCompare(a.data.title), |
34 | | - ); |
35 | | - }); |
36 | 21 | eleventyConfig.addFilter("fullUrl", (path) => { |
37 | 22 | return new URL(path, site.url).href; |
38 | 23 | }); |
39 | 24 | eleventyConfig.addFilter("isCurrentPage", (pageUrl, currentUrl) => { |
40 | 25 | return currentUrl.startsWith(pageUrl); |
41 | 26 | }); |
42 | | - eleventyConfig.addFilter("md", (content) => { |
43 | | - // TODO: this seems to have 11ty's syntax added already |
44 | | - return md.render(content); |
45 | | - }); |
46 | | - eleventyConfig.addFilter("json", (content) => |
47 | | - JSON.stringify(content, null, 2), |
48 | | - ); |
49 | | - eleventyConfig.addFilter("getPages", (collection, tags = []) => { |
50 | | - const set = new Set(tags); |
51 | | - return collection |
52 | | - .filter((item) => item.data.tags?.some((t) => set.has(t))) |
53 | | - .sort((a, b) => a.data.title?.localeCompare(b.data.title)); |
54 | | - }); |
55 | | - eleventyConfig.addFilter("slug", (text) => slugify(text)); |
56 | 27 |
|
57 | 28 | eleventyConfig.addShortcode("pkgVersion", () => pkg.version); |
58 | 29 | eleventyConfig.addPairedShortcode( |
59 | 30 | "error", |
60 | 31 | (content) => `<p class="eleventyError">${content}</p>`, |
61 | 32 | ); |
62 | 33 |
|
| 34 | + // TODO: add watch/rebuild for src in development mode? |
63 | 35 | // eleventyConfig.addWatchTarget('./source/**/*.css') |
64 | 36 | // eleventyConfig.addWatchTarget('./source/**/*.ts') |
65 | 37 | } |
|
0 commit comments