Skip to content

Commit

Permalink
fix scrolling to relevant section from clicking table of contents
Browse files Browse the repository at this point in the history
  • Loading branch information
tawandamoyo committed Aug 25, 2024
1 parent f4b8bb5 commit e413b6c
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/pages/BlogPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -697,21 +697,15 @@ function LeftContents(props) {
return text;
});
const headerSlugs = headers.map((header) =>
header
.split(" ")
.slice(1)
.join(" ")
.split(" ")
.join("-")
.replace("\\", "")
.replace(/,/g, ""),
header.replace(/[#,/]/g, "").trim().replace(/\s+/g, "-").toLowerCase(),
);

let contents = [];
for (let i = 0; i < headers.length; i++) {
const headerLevel = headerLevels[i];
const headerText = headerTexts[i];
const headerSlug = headerSlugs[i];

contents.push(
<div
style={{ display: "flex", alignItems: "center", marginBottom: 5 }}
Expand Down

0 comments on commit e413b6c

Please sign in to comment.