feat: add table of content element
Some checks failed
Deploy to SFTP Server / build (push) Has been cancelled
Some checks failed
Deploy to SFTP Server / build (push) Has been cancelled
This commit is contained in:
@@ -118,11 +118,11 @@ const { title, width = "compact" } = Astro.props;
|
||||
})();
|
||||
</script>
|
||||
</head>
|
||||
<body class=`layout-${width} bg-dark text-neutral p-2`>
|
||||
<body class="bg-dark text-neutral p-2 flex flex-col gap-4">
|
||||
<header>
|
||||
<Nav />
|
||||
</header>
|
||||
<main id="main-content" class="flex flex-col mt-4xl gap-y-2xl">
|
||||
<main id="main-content" class="flex flex-col gap-4">
|
||||
<slot />
|
||||
</main>
|
||||
<footer class="px-4 flex gap-8 mb-4">
|
||||
@@ -135,7 +135,7 @@ const { title, width = "compact" } = Astro.props;
|
||||
</a>
|
||||
</footer>
|
||||
<style>
|
||||
.layout-compact {
|
||||
body {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
import Layout from "./Layout.astro";
|
||||
import TOC from "@components/TOC.astro";
|
||||
import { useTranslatedPath, useTranslations } from "@i18n/utils";
|
||||
import type { MarkdownLayoutProps } from "astro";
|
||||
|
||||
@@ -10,7 +11,7 @@ type Props = MarkdownLayoutProps<{
|
||||
toc?: boolean;
|
||||
}>;
|
||||
|
||||
const { frontmatter } = Astro.props;
|
||||
const { frontmatter, headings } = Astro.props;
|
||||
const t = useTranslations(Astro.url);
|
||||
const { title, url, date: dateString, links, toc } = frontmatter;
|
||||
const collection = url?.split("/")[2];
|
||||
@@ -56,11 +57,12 @@ const backlinkContent = t(`nav.${collection}`).toLowerCase();
|
||||
</div>
|
||||
</div>
|
||||
<article class={`flex flex-col gap-4 ${toc ? "show-toc" : ""}`}>
|
||||
<div class="mb-4 flex flex-col gap-1">
|
||||
<div class="flex flex-col gap-1">
|
||||
<h1 class="text-4xl">
|
||||
{title}
|
||||
</h1>
|
||||
</div>
|
||||
{toc && <TOC headings={headings} />}
|
||||
<slot />
|
||||
</article>
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user