From d542e8b23d86489ef39798256f04833830b94e2c Mon Sep 17 00:00:00 2001 From: "Jocelyn Badgley (Twipped)" Date: Fri, 27 Aug 2021 11:53:38 -0700 Subject: [PATCH] Fix the broken header links --- build/engines.js | 5 +++-- build/lib/slugify.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build/engines.js b/build/engines.js index 59ab8f6..b08a052 100644 --- a/build/engines.js +++ b/build/engines.js @@ -31,10 +31,11 @@ const markdownEngines = { }, }) .use(mAnchor, { - permalink: mAnchor.permalink.ariaHidden({ + permalink: mAnchor.permalink.linkInsideHeader({ class: 'header-link', symbol: '', - renderHref: slugify, + renderHref: (input) => '#' + slugify(decodeURIComponent(input)), + ariaHidden: true, }), }) .use(require('./lib/markdown-raw-html'), { debug: false }), diff --git a/build/lib/slugify.js b/build/lib/slugify.js index c25be74..0f6ca72 100644 --- a/build/lib/slugify.js +++ b/build/lib/slugify.js @@ -1,5 +1,6 @@ const slugs = require('slugify'); module.exports = exports = function slugify (s) { - return slugs(s, { remove: /[*+~.,()'"!?:@/\\]/g }).toLowerCase(); + const result = slugs(s, { remove: /[*+~.,()'"!?:@/\\]/g }).toLowerCase(); + return result; };