From c362f4a488b6ad85e8f3cb4902ec0f26f2ca3a29 Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Thu, 17 Jul 2025 21:21:30 +0800 Subject: [PATCH] style(list.html): add proper code comments --- layouts/_default/list.html | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 117c8045..c6a50e77 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,5 +1,9 @@ {{ define "main" }} {{ .Scratch.Set "scope" "list" }} + {{ $enableToc := .Params.showTableOfContents | default (.Site.Params.list.showTableOfContents | default false) }} + {{ $showToc := and $enableToc (in .TableOfContents " {{ if .Params.showBreadcrumbs | default (.Site.Params.list.showBreadcrumbs | default false) }} {{ partial "breadcrumbs.html" . }} @@ -36,10 +39,12 @@ data-oid-likes="likes_{{ $path }}"> {{ end }} - {{ $tocMargin := cond $toc "mt-12" "mt-0" -}} + + {{/* Description (markdown content) */}} + {{ $tocMargin := cond $showToc "mt-12" "mt-0" }} {{ $topClass := cond (hasPrefix .Site.Params.header.layout "fixed") "lg:top-[140px]" "lg:top-10" }}
- {{ if $toc }} + {{ if $showToc }}
{{ partial "toc.html" . }} @@ -51,6 +56,7 @@
+ {{/* Article Grid */}} {{ if gt .Pages 0 }} {{ $cardView := .Params.cardView | default (.Site.Params.list.cardView | default false) }} {{ $cardViewScreenWidth := .Params.cardViewScreenWidth | default (.Site.Params.list.cardViewScreenWidth | default false) }} @@ -77,8 +83,8 @@ {{ end }} {{ end }} + {{/* else: is cardView */}} {{ else }} - {{ if $groupByYear }} {{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }} {{ if $cardViewScreenWidth }} @@ -86,8 +92,7 @@

{{ .Key }}

-
+
{{ range .Pages }} {{ partial "article-link/card.html" . }} {{ end }} @@ -97,8 +102,7 @@

{{ .Key }}

-
+
{{ range .Pages }} {{ partial "article-link/card.html" . }} {{ end }} @@ -106,6 +110,7 @@ {{ end }} {{ end }} + {{/* else: not groupByYear */}} {{ else }} {{ if $cardViewScreenWidth }}
@@ -137,10 +142,10 @@ {{ end }} {{ end }}
- {{ end }} - {{ end }} - - {{ end }} + {{ end }}{{/* End of cardViewScreenWidth */}} + {{ end }}{{/* End of groupByYear */}} + {{ end }}{{/* End of cardView */}} + {{/* else: .Pages not greater to zero */}} {{ else }}