refactor(list.html): make list.html formattable

This commit is contained in:
ZhenShuo Leo
2025-07-16 14:48:18 +08:00
parent 9bf09a8a3f
commit b0c3ac1321
2 changed files with 42 additions and 26 deletions

View File

@@ -27,7 +27,6 @@ static
layouts/_default/_markup/render-heading.html layouts/_default/_markup/render-heading.html
layouts/_default/index.json layouts/_default/index.json
layouts/_default/list.html
layouts/shortcodes/screenshot.html layouts/shortcodes/screenshot.html
layouts/shortcodes/figure.html layouts/shortcodes/figure.html
layouts/partials/hugo-embedded/shortcodes/figure-default.html layouts/partials/hugo-embedded/shortcodes/figure-default.html

View File

@@ -81,17 +81,24 @@
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }} {{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
{{ if $cardViewScreenWidth }} {{ if $cardViewScreenWidth }}
<div class="relative w-screen max-w-[1600px] px-[30px] left-[calc(max(-50vw,-800px)+50%)]"> <div class="relative w-screen max-w-[1600px] px-[30px] left-[calc(max(-50vw,-800px)+50%)]">
{{ end }} <h2 class="mt-12 mb-3 text-2xl font-bold text-neutral-700 first:mt-8 dark:text-neutral-300">
<h2 class="mt-12 mb-3 text-2xl font-bold text-neutral-700 first:mt-8 dark:text-neutral-300"> {{ .Key }}
{{ .Key }} </h2>
</h2> <section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3 {{ if $cardViewScreenWidth }} xl:grid-cols-4 2xl:grid-cols-5 {{ end }}">
<section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3 {{ if $cardViewScreenWidth }} xl:grid-cols-4 2xl:grid-cols-5 {{ end }}"> {{ range .Pages }}
{{ range .Pages }} {{ partial "article-link/card.html" . }}
{{ partial "article-link/card.html" . }} {{ end }}
{{ end }} </section>
</section>
{{ if $cardViewScreenWidth }}
</div> </div>
{{ else }}
<h2 class="mt-12 mb-3 text-2xl font-bold text-neutral-700 first:mt-8 dark:text-neutral-300">
{{ .Key }}
</h2>
<section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3 {{ if $cardViewScreenWidth }} xl:grid-cols-4 2xl:grid-cols-5 {{ end }}">
{{ range .Pages }}
{{ partial "article-link/card.html" . }}
{{ end }}
</section>
{{ end }} {{ end }}
{{ end }} {{ end }}
@@ -99,24 +106,34 @@
{{ if $cardViewScreenWidth }} {{ if $cardViewScreenWidth }}
<div class="relative w-screen max-w-[1600px] px-[30px] left-[calc(max(-50vw,-800px)+50%)]"> <div class="relative w-screen max-w-[1600px] px-[30px] left-[calc(max(-50vw,-800px)+50%)]">
<section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5"> <section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5">
{{ if not $orderByWeight }}
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
{{ range .Pages }}
{{ partial "article-link/card.html" . }}
{{ end }}
{{ end }}
{{ else }}
{{ range (.Paginate (.Pages.ByWeight)).Pages }}
{{ partial "article-link/card.html" . }}
{{ end }}
{{ end }}
</section>
</div>
{{ else }} {{ else }}
<section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3"> <section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3">
{{ end }} {{ if not $orderByWeight }}
{{ if not $orderByWeight }} {{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }} {{ range .Pages }}
{{ range .Pages }} {{ partial "article-link/card.html" . }}
{{ partial "article-link/card.html" . }} {{ end }}
{{ end }}
{{ else }}
{{ range (.Paginate (.Pages.ByWeight)).Pages }}
{{ partial "article-link/card.html" . }}
{{ end }}
{{ end }} {{ end }}
{{ end }} </section>
{{ else }}
{{ range (.Paginate (.Pages.ByWeight)).Pages }}
{{ partial "article-link/card.html" . }}
{{ end }}
{{ end }}
</section>
{{ if $cardViewScreenWidth }}
</div>
{{ end }} {{ end }}
{{ end }} {{ end }}