clean structure of layouts/ and add support for taxonomys

This commit is contained in:
Hanwen Guo 2022-08-27 21:24:22 +08:00
parent 550b0f47b7
commit 10130c4963
7 changed files with 32 additions and 34 deletions

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ $.Site.LanguageCode }}" class="han-init"> <html lang="{{ $.Site.LanguageCode }}" class="{{- if $.Site.Params.hasCJKLanguage -}} {{- "han-init" -}} {{- end -}}">
{{- partial "head.html" . -}} {{- partial "head.html" . -}}
<body a="{{ $.Site.Params.theme_config.appearance | default "auto" }}"> <body a="{{ $.Site.Params.theme_config.appearance | default "auto" }}">
<main class="page-content" aria-label="Content"> <main class="page-content" aria-label="Content">

View File

@ -0,0 +1,8 @@
{{ define "main" }}
{{ partial "back_link.html" .}}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ partial "post_list.html" (dict "context" .)}}
{{ end }}

View File

@ -0,0 +1,8 @@
{{ define "main" }}
{{ partial "back_link.html" .}}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ partial "post_list.html" (dict "context" .)}}
{{ end }}

View File

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html lang="{{ $.Site.LanguageCode }}" class="han-init">
{{- partial "head.html" . -}}
<body a="{{ $.Site.Params.theme_config.appearance | default "auto" }}">
<main class="page-content" aria-label="Content">
<div class="w">
{{- block "main" . }}{{- end }}
</div>
</main>
<script src="https://cdn.jsdelivr.net/npm/han-css@3/dist/han.min.js"></script>
</body>
</html>

View File

@ -8,6 +8,10 @@
{{- end -}} {{- end -}}
</li> </li>
{{- if $item.entries }}
{{ partial "menu_item.html" (dict "context" . "collection" $item.entries) }}
{{- end -}}
{{- if $item.post_list -}} {{- if $item.post_list -}}
{{ partial "post_list.html" (dict {{ partial "post_list.html" (dict
"context" . "context" .
@ -18,9 +22,5 @@
"show_more_url" $item.post_list.show_more_url "show_more_url" $item.post_list.show_more_url
) -}} ) -}}
{{- end -}} {{- end -}}
{{- if $item.entries }}
{{ partial "menu_item.html" (dict "context" . "collection" $item.entries) }}
{{- end -}}
{{- end -}} {{- end -}}
</ul> </ul>

View File

@ -2,9 +2,17 @@
{{- if .section -}} {{- if .section -}}
{{- $posts = (where site.RegularPages "Section" .section) -}} {{- $posts = (where site.RegularPages "Section" .section) -}}
{{- else -}}
{{- if (eq .context.Kind "taxonomy") -}}
{{- $posts = .context.Pages -}}
{{- else -}}
{{- if (eq .context.Kind "term") -}}
{{- $posts = .context.Data.Pages -}}
{{- else -}} {{- else -}}
{{- $posts = site.RegularPages }} {{- $posts = site.RegularPages }}
{{- end -}} {{- end -}}
{{- end -}}
{{- end -}}
{{- $limit_exceeded:= "" -}} {{- $limit_exceeded:= "" -}}
{{- if (and .limit (gt (len $posts) .limit)) -}} {{- if (and .limit (gt (len $posts) .limit)) -}}

View File

@ -1,13 +0,0 @@
{{ if .IsNamedParams }}
{{ with .Get "text" }}
<hr data-content='{{ . }}' />
{{ else }}
<hr />
{{ end }}
{{ else }}
{{ with .Get 0 }}
<hr data-content="{{ . }}" />
{{ else }}
<hr />
{{ end }}
{{ end }}