Use indentation inside templating blocks for better readability

This commit is contained in:
BBaoVanC 2021-11-22 02:21:15 -06:00
parent e1e211a42a
commit ead88d5e16
Signed by: bbaovanc
GPG Key ID: 18089E4E3CCF1D3A
24 changed files with 310 additions and 326 deletions

View File

@ -1,6 +1,5 @@
{{ define "main" }} {{ define "main" }}
<h1>
<h1>
{{ with .Params.icon }}{{ partial "icon.html" . }}{{ end }} {{ with .Params.icon }}{{ partial "icon.html" . }}{{ end }}
{{ .Title | markdownify }} {{ .Title | markdownify }}
<span class="rss-link"> <span class="rss-link">
@ -8,9 +7,9 @@
<a href="{{ .Permalink }}" target="_blank" rel="noopener">{{ partial "icon.html" "rss-feed" }}</a> <a href="{{ .Permalink }}" target="_blank" rel="noopener">{{ partial "icon.html" "rss-feed" }}</a>
{{ end }} {{ end }}
</span> </span>
</h1> </h1>
<div class="list-page-content"> <div class="list-page-content">
{{ with .Sections }} {{ with .Sections }}
<div class="sections"> <div class="sections">
{{ range . }} {{ range . }}
@ -30,8 +29,7 @@
{{ end }} {{ end }}
</ul> </ul>
</div> </div>
</div> </div>
{{ partial "pagination.html" . }}
{{ partial "pagination.html" . }}
{{ end }} {{ end }}

View File

@ -1,22 +1,20 @@
{{ define "main" }} {{ define "main" }}
<div class="post-title"> <div class="post-title">
<h1> <h1>
{{ .Title | markdownify }} {{ .Title | markdownify }}
{{ if .Draft }}{{ partial "icon.html" "write" }}{{ end }} {{ if .Draft }}{{ partial "icon.html" "write" }}{{ end }}
</h1> </h1>
</div> </div>
{{ partial "post-metadata/full.html" . }} {{ partial "post-metadata/full.html" . }}
{{ with (.GetTerms "series") }}
{{ $series := slice }}
{{ range . }}
{{ $series = $series | append (printf `<a href="%s">%s</a>` .Permalink .LinkTitle) }}
{{ end }}
{{ with (.GetTerms "series") }} <div class="series-box">
{{ $series := slice }}
{{ range . }}
{{ $series = $series | append (printf `<a href="%s">%s</a>` .Permalink .LinkTitle) }}
{{ end }}
<div class="series-box">
{{ partial "icon.html" "info" }} {{ partial "icon.html" "info" }}
{{ if gt (len $series) 1 }} {{ if gt (len $series) 1 }}
This post is part of multiple series: This post is part of multiple series:
@ -25,35 +23,34 @@
{{ end }} {{ end }}
{{ delimit $series ", " }} {{ delimit $series ", " }}
</div> </div>
{{ end }}
{{ end }}
{{ if .Params.Toc }} {{ if .Params.Toc }}
<div class="table-of-contents"> <div class="table-of-contents">
<details> <details>
<summary>{{ i18n "table_of_contents" }}</summary> <summary>{{ i18n "table_of_contents" }}</summary>
{{ .TableOfContents }} {{ .TableOfContents }}
</details> </details>
</div> </div>
<div class="table-of-contents print"> <div class="table-of-contents print">
{{ i18n "table_of_contents" }} {{ i18n "table_of_contents" }}
{{ .TableOfContents }} {{ .TableOfContents }}
</div> </div>
{{ end }} {{ end }}
{{ with .Resources.GetMatch "feature" }} {{ with .Resources.GetMatch "feature" }}
<div class="post-media"> <div class="post-media">
{{ partial "figure.html" (dict "src" . "border" true) }} {{ partial "figure.html" (dict "src" . "border" true) }}
</div> </div>
{{ end }} {{ end }}
{{ .Content }} {{ .Content }}
{{ $related := .Site.RegularPages.Related . | first 5 }} {{ $related := .Site.RegularPages.Related . | first 5 }}
{{ with $related }} {{ with $related }}
<div class="see-also"> <div class="see-also">
<h2>{{ i18n "see_also" }}</h2> <h2>{{ i18n "see_also" }}</h2>
<ul> <ul>
@ -64,11 +61,11 @@
</li> </li>
{{ end }} {{ end }}
</ul> </ul>
</div> </div>
{{ end }} {{ end }}
{{ if or .NextInSection .PrevInSection }} {{ if or .NextInSection .PrevInSection }}
<div class="prevnext"> <div class="prevnext">
{{ with .NextInSection }} {{ with .NextInSection }}
<a class="prev" href="{{ .Permalink }}"> <a class="prev" href="{{ .Permalink }}">
<div class="prev-caption"> <div class="prev-caption">
@ -94,13 +91,12 @@
{{ else }} {{ else }}
<div class="next"></div> <div class="next"></div>
{{ end }} {{ end }}
</div> </div>
{{ end }} {{ end }}
{{ if .Params.comments }} {{ if .Params.comments }}
<div class="comments"> <div class="comments">
{{ partial "comments.html" . }} {{ partial "comments.html" . }}
</div> </div>
{{ end }} {{ end }}
{{ end }} {{ end }}

View File

@ -1,12 +1,12 @@
{{ $hidecaption := index . "hidecaption" }} {{ $hidecaption := index . "hidecaption" }}
{{ if index . "noborder" }} {{ if index . "noborder" }}
<figure> <figure>
{{ else }} {{ else }}
<figure class="border"> <figure class="border">
{{ end }} {{ end }}
{{ with index . "src" }}
{{ with index . "src" }}
{{ $media := . }} {{ $media := . }}
{{ if eq .MediaType.MainType "image" }} {{ if eq .MediaType.MainType "image" }}
<img src="{{ $media.Permalink }}" alt="{{ $media.Title }}" /> <img src="{{ $media.Permalink }}" alt="{{ $media.Title }}" />
@ -24,6 +24,5 @@
</figcaption> </figcaption>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
</figure> </figure>

View File

@ -1,19 +1,16 @@
{{ with .Params.authors }} {{ with .Params.authors }}
<span class="post-meta-item"> <span class="post-meta-item">
{{ partial "icon.html" "user-circle" }} {{ partial "icon.html" "user-circle" }}
{{ if index $.Site.Taxonomies "authors" }} {{ if index $.Site.Taxonomies "authors" }}
{{ $authors := slice }} {{ $authors := slice }}
{{ range . }} {{ range . }}
{{ $url := (printf "authors/%s" (. | anchorize)) | absLangURL }} {{ $url := (printf "authors/%s" (. | anchorize)) | absLangURL }}
{{ $authors = $authors | append (printf `<a href="%s">%s</a>` $url . | safeHTML) }} {{ $authors = $authors | append (printf `<a href="%s">%s</a>` $url . | safeHTML) }}
{{ end }} {{ end }}
{{ delimit $authors ", " }} {{ delimit $authors ", " }}
{{ else }} {{ else }}
{{ delimit . ", " }} {{ delimit . ", " }}
{{ end }} {{ end }}
</span> </span>
{{ end }} {{ end }}

View File

@ -1,6 +1,6 @@
{{ if ne .Site.Params.readingtime false }} {{ if ne .Site.Params.readingtime false }}
<span class="post-meta-item"> <span class="post-meta-item">
{{ partial "icon.html" "clock" }} {{ partial "icon.html" "clock" }}
{{ i18n "readingtime" .ReadingTime }} {{ i18n "readingtime" .ReadingTime }}
</span> </span>
{{ end }} {{ end }}

View File

@ -1,12 +1,11 @@
{{ with (.GetTerms "series") }} {{ with (.GetTerms "series") }}
{{ $series := slice }}
{{ range . }}
{{ $series = $series | append (printf `<a href="%s">%s</a>` .Permalink .LinkTitle) }}
{{ end }}
{{ $series := slice }} <div class="series">
{{ range . }}
{{ $series = $series | append (printf `<a href="%s">%s</a>` .Permalink .LinkTitle) }}
{{ end }}
<div class="series">
{{ partial "icon.html" "files" }} {{ partial "icon.html" "files" }}
{{ delimit $series ", " }} {{ delimit $series ", " }}
</div> </div>
{{ end }} {{ end }}

View File

@ -1,12 +1,11 @@
{{ with (.GetTerms "tags") }} {{ with (.GetTerms "tags") }}
{{ $tags := slice }}
{{ range . }}
{{ $tags = $tags | append (printf `<a href="%s">%s</a>` .Permalink .LinkTitle) }}
{{ end }}
{{ $tags := slice }} <div class="tags">
{{ range . }}
{{ $tags = $tags | append (printf `<a href="%s">%s</a>` .Permalink .LinkTitle) }}
{{ end }}
<div class="tags">
{{ partial "icon.html" "tag" }} {{ partial "icon.html" "tag" }}
{{ delimit $tags ", " }} {{ delimit $tags ", " }}
</div> </div>
{{ end }} {{ end }}

View File

@ -1,8 +1,8 @@
{{ if .IsTranslated }} {{ if .IsTranslated }}
<span class="post-meta-item"> <span class="post-meta-item">
{{ partial "icon.html" "world" }} {{ partial "icon.html" "world" }}
{{ range .Translations }} {{ range .Translations }}
<a href="{{ .Permalink }}">{{ .Language }}</a> <a href="{{ .Permalink }}">{{ .Language }}</a>
{{ end }} {{ end }}
</span> </span>
{{ end }} {{ end }}

View File

@ -1,5 +1,5 @@
{{ if and .Site.Params.gitFileURL .File.Path }} {{ if and .Site.Params.gitFileURL .File.Path }}
<span class="post-meta-item"> <span class="post-meta-item">
{{ with .Site.Params.gitFileIcon }} {{ with .Site.Params.gitFileIcon }}
{{ partial "icon.html" . }} {{ partial "icon.html" . }}
{{ else }} {{ else }}
@ -9,5 +9,5 @@
<a href="{{ printf "%s/content/%s" .Site.Params.gitFileURL .File.Path }}" target="_blank" rel="noopener"> <a href="{{ printf "%s/content/%s" .Site.Params.gitFileURL .File.Path }}" target="_blank" rel="noopener">
View source View source
</a> </a>
</span> </span>
{{ end }} {{ end }}

View File

@ -1,5 +1,5 @@
{{ if or .Date .Params.authors .IsTranslated .Site.Params.readingtime .Site.Params.gitFileURL }} {{ if or .Date .Params.authors .IsTranslated .Site.Params.readingtime .Site.Params.gitFileURL }}
<div class="post-metadata"> <div class="post-metadata">
{{ if .Date }} {{ if .Date }}
<span class="post-meta-item"> <span class="post-meta-item">
{{ partial "icon.html" "calendar" }} {{ partial "icon.html" "calendar" }}
@ -24,5 +24,5 @@
{{ partial "post-meta-item/readingtime.html" . }} {{ partial "post-meta-item/readingtime.html" . }}
{{ partial "post-meta-item/viewsource.html" . }} {{ partial "post-meta-item/viewsource.html" . }}
{{ partial "post-meta-item/tags.html" . }} {{ partial "post-meta-item/tags.html" . }}
</div> </div>
{{ end }} {{ end }}

View File

@ -1,5 +1,5 @@
{{ if or .Date .Params.authors .IsTranslated .Site.Params.readingtime }} {{ if or .Date .Params.authors .IsTranslated .Site.Params.readingtime }}
<div class="post-metadata"> <div class="post-metadata">
{{ if .Date }} {{ if .Date }}
<span class="post-meta-item"> <span class="post-meta-item">
{{ partial "icon.html" "calendar" }} {{ partial "icon.html" "calendar" }}
@ -14,5 +14,5 @@
{{ partial "post-meta-item/readingtime.html" . }} {{ partial "post-meta-item/readingtime.html" . }}
{{ partial "post-meta-item/series.html" . }} {{ partial "post-meta-item/series.html" . }}
{{ partial "post-meta-item/tags.html" . }} {{ partial "post-meta-item/tags.html" . }}
</div> </div>
{{ end }} {{ end }}

View File

@ -4,10 +4,11 @@
{{ $alt := index . "alt" }} {{ $alt := index . "alt" }}
{{ if index . "border" }} {{ if index . "border" }}
<figure class="border"> <figure class="border">
{{ else }} {{ else }}
<figure> <figure>
{{ end }} {{ end }}
{{ if eq $type "image" }} {{ if eq $type "image" }}
<img src="{{ $src }}" alt="{{ $alt }}" /> <img src="{{ $src }}" alt="{{ $alt }}" />
{{ else if eq $type "video" }} {{ else if eq $type "video" }}

View File

@ -1,9 +1,7 @@
{{ with .Params.authors }} {{ with .Params.authors }}
<meta name="author" content="{{ delimit . ", " }}">
<meta name="author" content="{{ delimit . ", " }}"> {{ range . }}
<meta property="article:author" content="{{ . }}">
{{ range . }} {{ end }}
<meta property="article:author" content="{{ . }}">
{{ end }}
{{ end }} {{ end }}

View File

@ -9,14 +9,11 @@
{{ end }} {{ end }}
{{ range .Site.Menus.main }} {{ range .Site.Menus.main }}
{{ $isActive := false }} {{ $isActive := false }}
{{ if or ($.HasMenuCurrent .Menu .) ($.IsMenuCurrent .Menu .) }} {{ if or ($.HasMenuCurrent .Menu .) ($.IsMenuCurrent .Menu .) }}
{{ $isActive = true }} {{ $isActive = true }}
{{ end }} {{ end }}
<a class="navbar-item{{ if $isActive }} active{{ end }}" href="{{ .URL }}">{{ .Name }}</a> <a class="navbar-item{{ if $isActive }} active{{ end }}" href="{{ .URL }}">{{ .Name }}</a>
{{ end }} {{ end }}
</nav> </nav>

View File

@ -2,12 +2,12 @@
{{ $noborder := false }} {{ $noborder := false }}
{{ if .Get "noborder" }} {{ if .Get "noborder" }}
{{ $noborder = true }} {{ $noborder = true }}
{{ end }} {{ end }}
{{ $hidecaption := false }} {{ $hidecaption := false }}
{{ if .Get "hidecaption" }} {{ if .Get "hidecaption" }}
{{ $hidecaption = true }} {{ $hidecaption = true }}
{{ end }} {{ end }}
<p> <p>

View File

@ -1,11 +1,11 @@
{{ $border := false }} {{ $border := false }}
{{ if .Get "border" }} {{ if .Get "border" }}
{{ $border = true }} {{ $border = true }}
{{ end }} {{ end }}
{{ $hidecaption := false }} {{ $hidecaption := false }}
{{ if .Get "hidecaption" }} {{ if .Get "hidecaption" }}
{{ $hidecaption = true }} {{ $hidecaption = true }}
{{ end }} {{ end }}
<p> <p>

View File

@ -1,11 +1,11 @@
{{ $border := false }} {{ $border := false }}
{{ if .Get "border" }} {{ if .Get "border" }}
{{ $border = true }} {{ $border = true }}
{{ end }} {{ end }}
{{ $hidecaption := false }} {{ $hidecaption := false }}
{{ if .Get "hidecaption" }} {{ if .Get "hidecaption" }}
{{ $hidecaption = true }} {{ $hidecaption = true }}
{{ end }} {{ end }}
<p> <p>