From 5f44add9273ce08a7299fcc2e58a2397b736f94b Mon Sep 17 00:00:00 2001 From: maia arson crimew Date: Mon, 24 Jul 2023 15:38:03 +0200 Subject: [PATCH] make headings linkable --- .eleventy.js | 4 ++++ package-lock.json | 35 ++++++++++++++++++++++++++++++++++- package.json | 4 +++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/.eleventy.js b/.eleventy.js index 9c5f508..7a2397f 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -4,6 +4,8 @@ const timeToRead = require('eleventy-plugin-time-to-read'); const safeLinks = require('@sardine/eleventy-plugin-external-links'); const eleventySass = require("@11tyrocks/eleventy-plugin-sass-lightningcss"); const related = require("eleventy-plugin-related"); +const markdownIt = require("markdown-it"); +const markdownItAnchor = require("markdown-it-anchor"); module.exports = function (eleventyConfig) { const parseDate = (str) => { @@ -21,6 +23,8 @@ module.exports = function (eleventyConfig) { trimBlocks: true }); + eleventyConfig.setLibrary("md", markdownIt({ "html": true }).use(markdownItAnchor, { "level": 2 })); + eleventyConfig.addPlugin(pluginRss); eleventyConfig.addPlugin(syntaxHighlight); eleventyConfig.addPlugin(timeToRead); diff --git a/package-lock.json b/package-lock.json index e7c417e..578b7a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,9 @@ "@11tyrocks/eleventy-plugin-sass-lightningcss": "^1.0.3", "@sardine/eleventy-plugin-external-links": "^1.4.0", "eleventy-plugin-related": "^1.0.6", - "eleventy-plugin-time-to-read": "^1.3.0" + "eleventy-plugin-time-to-read": "^1.3.0", + "markdown-it": "^13.0.1", + "markdown-it-anchor": "^8.6.7" } }, "node_modules/@11ty/dependency-tree": { @@ -404,6 +406,28 @@ "node": ">=8" } }, + "node_modules/@types/linkify-it": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz", + "integrity": "sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==", + "peer": true + }, + "node_modules/@types/markdown-it": { + "version": "12.2.3", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", + "integrity": "sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==", + "peer": true, + "dependencies": { + "@types/linkify-it": "*", + "@types/mdurl": "*" + } + }, + "node_modules/@types/mdurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz", + "integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==", + "peer": true + }, "node_modules/@types/minimatch": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", @@ -1816,6 +1840,15 @@ "markdown-it": "bin/markdown-it.js" } }, + "node_modules/markdown-it-anchor": { + "version": "8.6.7", + "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz", + "integrity": "sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA==", + "peerDependencies": { + "@types/markdown-it": "*", + "markdown-it": "*" + } + }, "node_modules/markdown-it/node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", diff --git a/package.json b/package.json index 605cc93..3d060b0 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,8 @@ "@11tyrocks/eleventy-plugin-sass-lightningcss": "^1.0.3", "@sardine/eleventy-plugin-external-links": "^1.4.0", "eleventy-plugin-related": "^1.0.6", - "eleventy-plugin-time-to-read": "^1.3.0" + "eleventy-plugin-time-to-read": "^1.3.0", + "markdown-it": "^13.0.1", + "markdown-it-anchor": "^8.6.7" } }