Add initial Table of Contents

This commit is contained in:
vimux 2018-05-22 16:36:26 +03:00
parent 400fa05302
commit 8fc9a3c7c5
No known key found for this signature in database
GPG key ID: 5A34FDC4EE832E34
3 changed files with 40 additions and 1 deletions

View file

@ -1,4 +1,7 @@
# Post # Post
- id: post_toc
translation: Table of Contents
- id: meta_lastmod - id: meta_lastmod
translation: Updated translation: Updated

View file

@ -5,6 +5,12 @@
{{- partial "post_thumbnail.html" (dict "page" . ) }} {{- partial "post_thumbnail.html" (dict "page" . ) }}
<div class="post__meta meta mb">{{ partial "post_meta.html" . }}</div> <div class="post__meta meta mb">{{ partial "post_meta.html" . }}</div>
<h1 class="post__title">{{ .Title }}</h1> <h1 class="post__title">{{ .Title }}</h1>
{{ if eq .Params.toc true }}
<details class="post__toc toc" {{ if .Params.tocOpen }}open{{ end }}>
<summary class="toc__title">{{- T "post_toc" -}}</summary>
{{ .TableOfContents }}
</details>
{{ end }}
<div class="post__content">{{ .Content }}</div> <div class="post__content">{{ .Content }}</div>
<footer class="post__footer"> <footer class="post__footer">
{{ if .Params.tags }}{{ partial "post_tags.html" . }}{{ end }} {{ if .Params.tags }}{{ partial "post_tags.html" . }}{{ end }}

View file

@ -19,6 +19,7 @@ html {
article, article,
aside, aside,
details,
dialog, dialog,
figcaption, figcaption,
figure, figure,
@ -27,7 +28,8 @@ header,
hgroup, hgroup,
main, main,
nav, nav,
section { section,
summary {
display: block; display: block;
} }
@ -665,6 +667,34 @@ mark {
background: #151515; background: #151515;
} }
.post__toc {
background: #111;
padding: .5rem;
margin-bottom: 1rem;
color: #f8ae00;
list-style: none;
}
.post__toc[open] {
color: #fff;
}
.post__toc ul {
list-style: none;
padding-left: 0;
padding-top: 1rem;
}
.post__toc ul ul {
padding-left: 2rem;
padding-top: 0;
}
.toc__title {
padding: .25rem;
font-weight: 700;
}
/* Comments */ /* Comments */
.comments { .comments {
margin-top: .625rem; margin-top: .625rem;