refactor(list.html): use intermediate variable for complex condition
This commit is contained in:
@@ -9,7 +9,8 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{ $toc := and (.Params.showTableOfContents | default (.Site.Params.list.showTableOfContents | default false)) (in .TableOfContents "<ul") }}
|
{{ $enableToc := .Params.showTableOfContents | default (.Site.Params.list.showTableOfContents | default false) }}
|
||||||
|
{{ $showToc := and $enableToc (in .TableOfContents "<ul") }}
|
||||||
<header>
|
<header>
|
||||||
{{ if .Params.showBreadcrumbs | default (.Site.Params.list.showBreadcrumbs | default false) }}
|
{{ if .Params.showBreadcrumbs | default (.Site.Params.list.showBreadcrumbs | default false) }}
|
||||||
{{ partial "breadcrumbs.html" . }}
|
{{ partial "breadcrumbs.html" . }}
|
||||||
@@ -35,20 +36,12 @@
|
|||||||
data-oid-likes="likes_{{ $path }}"></script>
|
data-oid-likes="likes_{{ $path }}"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</header>
|
</header>
|
||||||
<section
|
{{ $tocMargin := cond $toc "mt-12" "mt-0" -}}
|
||||||
class="{{ if $toc -}}
|
{{ $topClass := cond (hasPrefix .Site.Params.header.layout "fixed") "lg:top-[140px]" "lg:top-10" }}
|
||||||
mt-12
|
<section class="{{ $tocMargin }} prose flex max-w-full flex-col dark:prose-invert lg:flex-row">
|
||||||
{{- else -}}
|
|
||||||
mt-0
|
|
||||||
{{- end }} prose flex max-w-full flex-col dark:prose-invert lg:flex-row">
|
|
||||||
{{ if $toc }}
|
{{ if $toc }}
|
||||||
<div class="order-first px-0 lg:order-last lg:max-w-xs ltr:lg:pl-8 rtl:lg:pr-8">
|
<div class="order-first px-0 lg:order-last lg:max-w-xs ltr:lg:pl-8 rtl:lg:pr-8">
|
||||||
<div
|
<div class="toc ltr:pl-5 rtl:pr-5 lg:sticky {{ $topClass }}">
|
||||||
class="toc ltr:pl-5 rtl:pr-5 lg:sticky {{ if hasPrefix .Site.Params.header.layout "fixed" -}}
|
|
||||||
lg:top-[140px]
|
|
||||||
{{ else }}
|
|
||||||
lg:top-10
|
|
||||||
{{ end }}">
|
|
||||||
{{ partial "toc.html" . }}
|
{{ partial "toc.html" . }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -94,9 +87,7 @@
|
|||||||
{{ .Key }}
|
{{ .Key }}
|
||||||
</h2>
|
</h2>
|
||||||
<section
|
<section
|
||||||
class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3 {{ if $cardViewScreenWidth }}
|
class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5">
|
||||||
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 }}
|
||||||
@@ -107,9 +98,7 @@
|
|||||||
{{ .Key }}
|
{{ .Key }}
|
||||||
</h2>
|
</h2>
|
||||||
<section
|
<section
|
||||||
class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3 {{ if $cardViewScreenWidth }}
|
class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3">
|
||||||
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 }}
|
||||||
|
|||||||
Reference in New Issue
Block a user