diff options
| author | Eltrac <hi@guhub.cn> | 2025-08-26 10:28:00 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-08-26 10:28:00 +0800 |
| commit | 6fc8a8a1e563bea6c9efcc19f2424f45009a71de (patch) | |
| tree | 3426f897eac1628bc3b5ef78eb4649c6561f7128 | |
| parent | 52345965347199d43452168fd4462e06e0dbdaf1 (diff) | |
feat: add toc to library and normal pages
Former-commit-id: e7f41626f0e3d8019562ef2d7a3d99e05e0b1e55
| -rw-r--r-- | content/about.md | 1 | ||||
| -rw-r--r-- | content/library/2025/在我身上有个不可战胜的夏天.md | 1 | ||||
| -rw-r--r-- | layouts/_partials/posts/toc.html | 3 | ||||
| -rw-r--r-- | layouts/library/page.html | 7 | ||||
| -rw-r--r-- | layouts/page.html | 1 | ||||
| -rw-r--r-- | layouts/posts/page.html | 7 |
6 files changed, 10 insertions, 10 deletions
diff --git a/content/about.md b/content/about.md index 142919af..23c6d43a 100644 --- a/content/about.md +++ b/content/about.md @@ -2,6 +2,7 @@ created: 2024-11-27T22:27 title: 关于 date: 2024-11-27 +toc: true --- {{< callout "你可以加入本博客的 Telegram 频道「[大脑充血](https://t.me/geedeapro)」,我会在这里发表一些不成文的想法。" "🧠" >}} diff --git a/content/library/2025/在我身上有个不可战胜的夏天.md b/content/library/2025/在我身上有个不可战胜的夏天.md index afbe8de2..b57bc046 100644 --- a/content/library/2025/在我身上有个不可战胜的夏天.md +++ b/content/library/2025/在我身上有个不可战胜的夏天.md @@ -12,6 +12,7 @@ genre: 文学 rating: 3 cover: https://image.guhub.cn/uPic/2025/08/s35195741.jpg draft: false +toc: true --- 关于加缪会不会成为我最喜欢的法国作家,这一点还有待商榷,毕竟我读的法国文学并不算多,对欧洲哲学的理解也很匮乏;在此之前只读过十八、十九世纪法国作家司汤达和福楼拜的代表作,也就是《[红与黑](/library/2025/红与黑)》和《[包法利夫人](/library/2025/包法利夫人/)》,加缪的文章里也提到过这两位作家。《在我身上有个不可战胜的夏天》是加缪的散文集,由《反与正》《婚礼集》和《夏天集》三部集子组成。我向来不是很爱读散文,对写景尤其不感兴趣,而《婚礼集》和《夏天集》里却充满了加缪对自然和城市的爱与不屑,再加上对希腊神话等欧洲文化了解甚少,读起这本书来很是吃力,只能摘选一些我能理解并有所感悟的部分做些评价——这也是为什么,我没有给这本书打很高的分数。<!--more--> diff --git a/layouts/_partials/posts/toc.html b/layouts/_partials/posts/toc.html index ea87bb26..0bc96782 100644 --- a/layouts/_partials/posts/toc.html +++ b/layouts/_partials/posts/toc.html @@ -1,7 +1,8 @@ +{{ $top := cond (eq .Section "posts") "top-[19rem]" (cond (eq .Section "library") "top-[34rem]" "top-[17rem]") }} {{ if .Params.toc }} <div id="toc-container" class="absolute bottom-0 left-[calc(50%_+_var(--page-width)_/_2)] right-auto - h-full w-[calc(50%_-_var(--page-width)_/_2)] top-[19rem] hidden lg:block"> + h-full w-[calc(50%_-_var(--page-width)_/_2)] {{ $top }} hidden lg:block"> <div id="toc" class="sticky top-12 text-size-xs xl:text-size-sm 2xl:text-size-base w-full" >{{ .TableOfContents }}</div> diff --git a/layouts/library/page.html b/layouts/library/page.html index e8760b60..1e9753a5 100644 --- a/layouts/library/page.html +++ b/layouts/library/page.html @@ -27,8 +27,9 @@ </p> </header> - <div class="markdown-body"> - <div class="leading-loose">{{ .Content }}</div> + <div class="markdown-body leading-loose"> + {{ partial "posts/toc" . }} + <div>{{ .Content }}</div> {{ partial "posts/endnotes" . }} </div> @@ -43,7 +44,7 @@ {{ $books := where (where .Site.RegularPages "Section" "library") ".Params.author" "==" .Params.author }} {{ $thisBookID := .File.UniqueID }} - {{ if gt (count $books) 1 }} + {{ if gt (len $books) 1 }} <h2>我读过的{{ .Params.author }}的其它书籍</h2> <div class="grid grid-cols-4 md:grid-cols-6 items-center gap-4 my-4"> {{ range $books }} diff --git a/layouts/page.html b/layouts/page.html index e8e4221b..7b01bf7c 100644 --- a/layouts/page.html +++ b/layouts/page.html @@ -3,6 +3,7 @@ <article> <div id="post-content" class="post-content markdown-body leading-loose" style="view-transition-name: post-content-{{ .File.UniqueID }}"> + {{ partial "posts/toc" . }} {{ .Content }} </div> </article> diff --git a/layouts/posts/page.html b/layouts/posts/page.html index 545be626..ef891f7e 100644 --- a/layouts/posts/page.html +++ b/layouts/posts/page.html @@ -37,13 +37,8 @@ <!-- Post Content --> <div class="min-h-[60%] leading-loose mb-8 markdown-body" style="view-transition-name: post-content-{{ .File.UniqueID }}"> - <!-- TOC --> {{ partial "posts/toc" . }} - <!-- Content --> - <div id="post-content"> - {{ .Content }} - </div> - <!-- Endnotes --> + <div id="post-content">{{ .Content }}</div> {{ partial "posts/endnotes" . }} </div> |
