Skip to content

Commit

Permalink
Merge pull request #98 from otegami/upgrade-eleventy-from-2-to-3
Browse files Browse the repository at this point in the history
Upgrade Eleventy from 2 to 3
  • Loading branch information
otegami authored Nov 4, 2024
2 parents 1eefe1a + 2aaeed3 commit 3d1cda1
Show file tree
Hide file tree
Showing 3 changed files with 1,094 additions and 914 deletions.
50 changes: 27 additions & 23 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const markdownItAnchor = require('markdown-it-anchor');
const markdownItToc = require('markdown-it-toc-done-right');
import { EleventyHtmlBasePlugin } from "@11ty/eleventy";
import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
import markdownItAnchor from "markdown-it-anchor";
import markdownItToc from "markdown-it-toc-done-right";
import markdownIt from "markdown-it";

// enable everything
var md = require('markdown-it')({
html: true,
linkify: true,
typographer: true
});
export default function (eleventyConfig) {
eleventyConfig.setLibrary("md", markdownIt({
html: true,
linkify: true,
typographer: true
}));

module.exports = function(eleventyConfig) {
md.use(markdownItAnchor, { // add anchors to headings
level: '2',
permalink: markdownItAnchor.permalink.ariaHidden({
class: 'anchor',
symbol: '#',
placement: 'before'
}),
eleventyConfig.amendLibrary("md", (mdLib) => {
return mdLib.use(markdownItAnchor, { // add anchors to headings
level: '2',
permalink: markdownItAnchor.permalink.ariaHidden({
class: 'anchor',
symbol: '#',
placement: 'before'
})
});
});
md.use(markdownItToc, { // make a TOC with ${toc}
level: '2',
listType: 'ul'

eleventyConfig.amendLibrary("md", (mdLib) => {
return mdLib.use(markdownItToc, { // make a TOC with ${toc}
level: '2',
listType: 'ul'
});
});

eleventyConfig.addCollection('turbo_handbook', collectionApi => {
Expand All @@ -38,8 +43,7 @@ module.exports = function(eleventyConfig) {

eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addPassthroughCopy({ '_assets': 'assets' });
eleventyConfig.setLibrary('md', md);
eleventyConfig.addPassthroughCopy({'_assets': 'assets'});
eleventyConfig.setDataDeepMerge(true);

return {
Expand Down
Loading

0 comments on commit 3d1cda1

Please sign in to comment.