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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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