diff --git a/packages/docusaurus-search-local/src/server/parse.ts b/packages/docusaurus-search-local/src/server/parse.ts index 1ccb6b0..60ade8e 100644 --- a/packages/docusaurus-search-local/src/server/parse.ts +++ b/packages/docusaurus-search-local/src/server/parse.ts @@ -124,7 +124,10 @@ 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) {