mirror of
https://github.com/anotherhadi/blog.git
synced 2026-05-20 05:32:32 +02:00
Fix TOC links
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import NoteTOC from "../../components/NoteTOC.astro";
|
|||||||
import NoteNavSidebar from "../../components/NoteNavSidebar.astro";
|
import NoteNavSidebar from "../../components/NoteNavSidebar.astro";
|
||||||
import NoteGraphSidebar from "../../components/NoteGraphSidebar.astro";
|
import NoteGraphSidebar from "../../components/NoteGraphSidebar.astro";
|
||||||
import NoteVars from "../../components/NoteVars.svelte";
|
import NoteVars from "../../components/NoteVars.svelte";
|
||||||
import { getCategory, extractLinks, extractExternalLinks, extractHeadings } from "../../utils/notes";
|
import { getCategory, extractLinks, extractExternalLinks } from "../../utils/notes";
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const notes = await getCollection("notes");
|
const notes = await getCollection("notes");
|
||||||
@@ -17,7 +17,7 @@ export async function getStaticPaths() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { entry } = Astro.props;
|
const { entry } = Astro.props;
|
||||||
const { Content } = await render(entry);
|
const { Content, headings: astroHeadings } = await render(entry);
|
||||||
|
|
||||||
const allNotes = await getCollection("notes");
|
const allNotes = await getCollection("notes");
|
||||||
const sortedNotes = allNotes.sort((a, b) =>
|
const sortedNotes = allNotes.sort((a, b) =>
|
||||||
@@ -60,7 +60,7 @@ const noteVars = [
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
const headings = extractHeadings(entry.body ?? "");
|
const headings = astroHeadings.map((h) => ({ depth: h.depth, text: h.text, id: h.slug }));
|
||||||
const externalLinks = extractExternalLinks(entry.body ?? "");
|
const externalLinks = extractExternalLinks(entry.body ?? "");
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user