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 e6fa809
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/docusaurus-search-local/src/server/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ 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) {
// $(heading) is the page title
Expand Down

0 comments on commit e6fa809

Please sign in to comment.