From e6fa8098417c233b985b21c9736f9993b4a8585c Mon Sep 17 00:00:00 2001 From: Amauri Dias Date: Thu, 18 Jul 2024 00:34:27 -0300 Subject: [PATCH] fix: Hash link parser for Docusaurus version 3 --- packages/docusaurus-search-local/src/server/parse.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus-search-local/src/server/parse.ts b/packages/docusaurus-search-local/src/server/parse.ts index 1ccb6b0..4f59ed7 100644 --- a/packages/docusaurus-search-local/src/server/parse.ts +++ b/packages/docusaurus-search-local/src/server/parse.ts @@ -124,8 +124,9 @@ export function html2text( // # .not("a[aria-hidden=true], a.hash-link") .text(); - const hash = $(heading).find("a.hash-link").attr("href") || ""; - + const linkHash = $(heading).find("a.hash-link").attr("href") || ""; + const [, hashPart] = linkHash.split("#"); + const hash = hashPart ? `#${hashPart}` : ""; let $sectionElements; if ($(heading).parents(".markdown").length === 0) { // $(heading) is the page title