From ddf10203f9ff5a1196b29fbf78221bd5fe266b46 Mon Sep 17 00:00:00 2001 From: Helen Chong <119173961+helenclx@users.noreply.github.com> Date: Thu, 6 Jun 2024 07:44:44 +0800 Subject: [PATCH] Add manual heading anchor paired shortcode --- eleventy.config.js | 8 ++++++++ src/_includes/main/changelogs-list.njk | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/eleventy.config.js b/eleventy.config.js index d877bd46..7653a3f2 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -61,6 +61,14 @@ module.exports = function (eleventyConfig) { // Shortcode: tag eleventyConfig.addShortcode('cite', (str) => `${str}`); + // Paired shortcode: Manual heading anchor + eleventyConfig.addPairedShortcode('headingAnchor', (title, hLevel, id) => { + return `
+ ${title} + +
`; + }); + return { dir: { input: "src" diff --git a/src/_includes/main/changelogs-list.njk b/src/_includes/main/changelogs-list.njk index b593b8ca..73da18d3 100644 --- a/src/_includes/main/changelogs-list.njk +++ b/src/_includes/main/changelogs-list.njk @@ -1,7 +1,7 @@ {% for log in changelogList | reverse %} -
-

{{ log.date | formatDate }}

- -
+ {% headingAnchor 2, log.fileSlug %} + {{ log.date | formatDate }} + {% endheadingAnchor %} + {{ log.templateContent | safe }} {%- endfor %}