Skip to content

Commit

Permalink
fix: Hash link parser for Docusaurus version 3
Browse files Browse the repository at this point in the history
  • Loading branch information
fxamauri committed Jul 18, 2024
1 parent 9c4f5f7 commit cdea9c5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/docusaurus-search-local/src/server/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ export function html2text(
// <a class="hash-link" href="#first-header" title="Direct link to heading">#</a>
.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) {
Expand Down

0 comments on commit cdea9c5

Please sign in to comment.