diff --git a/src/components/TableOfContents.astro b/src/components/TableOfContents.astro
index 19be069..458be58 100644
--- a/src/components/TableOfContents.astro
+++ b/src/components/TableOfContents.astro
@@ -2,9 +2,10 @@
interface Props {
headings: Array<{ depth: number; slug: string; text: string }>
label: string
+ title?: string
}
-const { headings, label } = Astro.props
+const { headings, label, title } = Astro.props
const tocHeadings = headings.filter((h) => h.depth === 2 || h.depth === 3)
---
@@ -23,6 +24,17 @@ const tocHeadings = headings.filter((h) => h.depth === 2 || h.depth === 3)
style="top: 0; left: -9px;"
/>
+ {title && (
+ -
+
+ {title}
+
+
+ )}
{tocHeadings.map((h) => (
-
h.depth === 2 || h.depth === 3)
if (top === undefined) return
const depth = depths.get(slug) || 2
- const indent = depth === 3 ? 12 : 0
+ const indent = depth >= 3 ? 12 : 0
indicator.style.top = `${top}px`
indicator.style.left = `${-9 + indent}px`
diff --git a/src/pages/articles/[slug].astro b/src/pages/articles/[slug].astro
index e6d72b3..b9d7dc1 100644
--- a/src/pages/articles/[slug].astro
+++ b/src/pages/articles/[slug].astro
@@ -118,7 +118,10 @@ const onThisPageLabel = t(labels, 'article.onThisPage')
{article.data.category}
-
+
{article.data.title}
-
+
diff --git a/src/pages/en/articles/[slug].astro b/src/pages/en/articles/[slug].astro
index 37fbb26..856c651 100644
--- a/src/pages/en/articles/[slug].astro
+++ b/src/pages/en/articles/[slug].astro
@@ -117,7 +117,10 @@ const onThisPageLabel = t(labels, 'article.onThisPage')
{article.data.category}
-
+
{article.data.title}
-
+
diff --git a/src/styles/global.css b/src/styles/global.css
index ba0e342..734f7ec 100644
--- a/src/styles/global.css
+++ b/src/styles/global.css
@@ -2,6 +2,10 @@
border-color: hsl(var(--border));
}
+html {
+ scroll-behavior: smooth;
+}
+
body {
background-color: hsl(var(--background));
color: hsl(var(--foreground));
@@ -77,3 +81,9 @@ html .astro-code span {
color: var(--shiki-light) !important;
background-color: var(--shiki-light-bg) !important;
}
+
+.prose h2,
+.prose h3,
+.prose h4 {
+ scroll-margin-top: 5rem;
+}