feat: add a table of content on blog posts

This commit is contained in:
Bruno Carlin 2025-07-06 14:22:12 +02:00
parent 874def264c
commit 1f0c9ae560
Signed by: bcarlin
GPG key ID: 8E254EA0FFEB9B6D
5 changed files with 51 additions and 0 deletions

View file

@ -266,6 +266,43 @@ main {
} }
} }
section.table-of-contents {
font-size: 0.9em;
margin-block-end: 2em;
margin-inline-start: 1em;
padding-inline-start: 1em;
border-inline-start: 1px solid var(--pico-muted-color);
p {
margin-bottom: 0; /* reset pico styles */
margin-block-end: 0.2em;
font-weight: bold;
}
nav {
ol {
&:last-of-type {
margin-right: initial; /* reset pico styles */
}
&:first-of-type {
margin-left: initial; /* reset pico styles */
}
li {
display: list-item; /* reset pico styles */
padding: initial; /* reset pico styles */
list-style-type: none;
ol {
margin-inline-start: 1em !important;
}
}
}
}
}
ul > li { ul > li {
list-style-type: disc; list-style-type: disc;
} }

View file

@ -41,3 +41,5 @@ markup:
goldmark: goldmark:
parser: parser:
wrapStandAloneImageWithinParagraph: false wrapStandAloneImageWithinParagraph: false
tableOfContents:
ordered: true

View file

@ -18,3 +18,4 @@ tags: Tags
information_icon: Information icon information_icon: Information icon
warning_icon: Warning icon warning_icon: Warning icon
also_available_in: "Also available in:" also_available_in: "Also available in:"
table_of_contents: "Contents:"

View file

@ -18,3 +18,4 @@ tags: Tags
information_icon: Icône information information_icon: Icône information
warning_icon: Icône attention warning_icon: Icône attention
also_available_in: "Également disponible en :" also_available_in: "Également disponible en :"
table_of_contents: "Contenu :"

View file

@ -23,6 +23,16 @@
</div> </div>
</header> </header>
{{ with .TableOfContents }}
{{- if ne . `<nav id="TableOfContents"></nav>` }}
<section class="table-of-contents">
<p>{{ T "table_of_contents" }}</p>
{{ . }}
</section>
{{- end }}
{{- end }}
<section class="e-content"> <section class="e-content">
{{ .Content }} {{ .Content }}
</section> </section>