From 772df1da56ead3c51dee9af8c6e1a8c94c6483bf Mon Sep 17 00:00:00 2001 From: Ming Di Leom <2809763-curben@users.noreply.gitlab.com> Date: Sat, 8 Jun 2024 02:46:12 +0000 Subject: [PATCH] fix(heading-link): detect repeat heading per post --- themes/chameleon/scripts/heading-link.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/chameleon/scripts/heading-link.js b/themes/chameleon/scripts/heading-link.js index 107d0b0..675de8a 100644 --- a/themes/chameleon/scripts/heading-link.js +++ b/themes/chameleon/scripts/heading-link.js @@ -9,16 +9,16 @@ const { slugize, stripHTML, unescapeHTML: unescape } = require('hexo-util') const anchorId = (str, transformOption) => { - return slugize(stripHTML(unescape(str)).trim(), { transform: transformOption }); + return slugize(stripHTML(unescape(str)).trim(), { transform: transformOption }) } hexo.extend.filter.register('marked:renderer', function (renderer) { const { config } = this + const headingId = {} renderer.heading = function (text, level) { const { modifyAnchors } = config.marked - const transformOption = modifyAnchors; + const transformOption = modifyAnchors let id = anchorId(text, transformOption) - const headingId = {}; // Add a number after id if repeated if (headingId[id]) {