--- import { getCollection, render } from "astro:content"; import Layout from "../../layouts/Layout.astro"; import { List, PanelRight } from "@lucide/astro"; import NoteTOC from "../../components/NoteTOC.astro"; import NoteNavSidebar from "../../components/NoteNavSidebar.svelte"; import NoteGraphSidebar from "../../components/NoteGraphSidebar.astro"; import NoteVars from "../../components/NoteVars.svelte"; import { getCategory, extractLinks, extractHeadings } from "../../utils/notes"; export async function getStaticPaths() { const notes = await getCollection("notes"); return notes.map((entry) => ({ params: { slug: entry.id }, props: { entry }, })); } const { entry } = Astro.props; const { Content } = await render(entry); const allNotes = await getCollection("notes"); const sortedNotes = allNotes.sort((a, b) => a.data.title.localeCompare(b.data.title), ); const categories = [...new Set(allNotes.map(getCategory))].sort(); const allLinks = Object.fromEntries( allNotes.map((n) => [n.id, extractLinks(n.body ?? "")]), ); const forwardLinks = (allLinks[entry.id] ?? []) .map((id) => allNotes.find((n) => n.id === id)) .filter(Boolean) as typeof allNotes; const backlinks = allNotes.filter( (n) => n.id !== entry.id && (allLinks[n.id] ?? []).includes(entry.id), ); const graphNodes = [ { id: entry.id, title: entry.data.title, current: true }, ...forwardLinks.map((n) => ({ id: n.id, title: n.data.title, current: false, })), ...backlinks .filter((n) => !forwardLinks.some((f) => f.id === n.id)) .map((n) => ({ id: n.id, title: n.data.title, current: false })), ]; const graphEdges = [ ...forwardLinks.map((n) => ({ from: entry.id, to: n.id })), ...backlinks.map((n) => ({ from: n.id, to: entry.id })), ]; const noteVars = [ ...new Set( Array.from( (entry.body ?? "").matchAll(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g), (m) => m[1], ), ), ]; const headings = extractHeadings(entry.body ?? ""); ---

{entry.data.title}

{entry.data.description}

{ entry.data.tags.length > 0 && (
{entry.data.tags.map((tag) => ( {tag} ))}
) }