diff --git a/src/components/TableOfContents.astro b/src/components/TableOfContents.astro
new file mode 100644
index 0000000..19be069
--- /dev/null
+++ b/src/components/TableOfContents.astro
@@ -0,0 +1,161 @@
+---
+interface Props {
+ headings: Array<{ depth: number; slug: string; text: string }>
+ label: string
+}
+
+const { headings, label } = Astro.props
+
+const tocHeadings = headings.filter((h) => h.depth === 2 || h.depth === 3)
+---
+
+{
+ tocHeadings.length > 0 && (
+
+ )
+}
+
+
diff --git a/src/pages/articles/[slug].astro b/src/pages/articles/[slug].astro
index 800a88d..e6d72b3 100644
--- a/src/pages/articles/[slug].astro
+++ b/src/pages/articles/[slug].astro
@@ -3,6 +3,7 @@ import DocsLayout from '../../layouts/DocsLayout.astro'
import ShareButtons from '../../components/ShareButtons.astro'
import GitHubUserCard from '../../components/GitHubUserCard.astro'
import ReadingProgress from '../../components/ReadingProgress.astro'
+import TableOfContents from '../../components/TableOfContents.astro'
import { getCollection, render } from 'astro:content'
import { SITE } from '../../config.mjs'
import { getLangFromUrl, t } from '../../i18n/index.ts'
@@ -34,7 +35,7 @@ const ogImageUrl = `/og/${article.data.lang}/${article.data.slug}.png`
const publishedDate = new Date(article.data.date)
const isoDate = publishedDate.toISOString()
-const sections = headings.filter((h) => h.depth === 2).map((h) => h.text)
+const tocHeadings = headings.filter((h) => h.depth === 2 || h.depth === 3)
const jsonLdArticle = {
'@context': 'https://schema.org',
@@ -152,28 +153,6 @@ const onThisPageLabel = t(labels, 'article.onThisPage')
-
+
diff --git a/src/pages/en/articles/[slug].astro b/src/pages/en/articles/[slug].astro
index ada17c4..37fbb26 100644
--- a/src/pages/en/articles/[slug].astro
+++ b/src/pages/en/articles/[slug].astro
@@ -3,6 +3,7 @@ import DocsLayout from '../../../layouts/DocsLayout.astro'
import ShareButtons from '../../../components/ShareButtons.astro'
import GitHubUserCard from '../../../components/GitHubUserCard.astro'
import ReadingProgress from '../../../components/ReadingProgress.astro'
+import TableOfContents from '../../../components/TableOfContents.astro'
import { getCollection, render } from 'astro:content'
import { SITE } from '../../../config.mjs'
import { t } from '../../../i18n/index.ts'
@@ -35,7 +36,7 @@ const ogImageUrl = `/og/${article.data.slug}.png`
const publishedDate = new Date(article.data.date)
const isoDate = publishedDate.toISOString()
-const sections = headings.filter((h) => h.depth === 2).map((h) => h.text)
+const tocHeadings = headings.filter((h) => h.depth === 2 || h.depth === 3)
const jsonLdArticle = {
'@context': 'https://schema.org',
@@ -151,28 +152,6 @@ const onThisPageLabel = t(labels, 'article.onThisPage')
-
+