chore(style): update code style

This commit is contained in:
Dillon
2020-01-31 22:53:04 +08:00
parent 344f0a9f41
commit 2a7611b5ae
36 changed files with 1204 additions and 970 deletions

View File

@@ -1,11 +1,11 @@
{{ define "title" }}{{ .Title }} | {{ .Site.Title }}{{ end }}
{{- define "title" }}{{ .Title }} | {{ .Site.Title }}{{ end -}}
{{ define "content" }}
{{ $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }}
{{ $author := .Site.Author.name }}
{{ if isset .Params "author" }}
{{ $author = .Site.Author.name }}
{{ end }}
{{- define "content" -}}
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
{{- $author := .Site.Author.name -}}
{{- if isset .Params "author" -}}
{{- $author = .Site.Author.name -}}
{{- end }}
<article class="warpper">
<h1 class="post-title animated flipInX">{{ .Title }}</h1>
@@ -13,17 +13,17 @@
<div class="post-meta">
<div class="post-meta-main">
<a class="author" href="{{.Site.BaseURL }}" rel="author"><i class="fas fa-user-circle fa-fw"></i>{{ $author }}&nbsp;</a>
{{ with .Params.categories -}}
{{- with .Params.categories -}}
<span class="post-category">
{{ T "included" }}
{{ range . }}
{{- T "included" -}}
{{- range . -}}
{{- $name := . -}}
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}}
<i class="far fa-folder fa-fw"></i><a href="{{ .Permalink }}">{{ $name }}</a>
{{ end -}}
{{ end }}
{{- end -}}
{{- end -}}
</span>
{{- end }}
{{- end -}}
</div>
<div class="post-meta-other">
<i class="far fa-calendar-alt fa-fw"></i><time datetime={{ $publish_date }}>{{ $publish_date }}</time>&nbsp;
@@ -37,59 +37,70 @@
</div>
</div>
{{ with .Params.featured_image }}
{{- with .Params.featured_image -}}
<div class="post-featured-image">
{{ $res := resources.Get "svg/loading.svg" | minify }}
{{- $res := resources.Get "svg/loading.svg" | minify -}}
<img src="{{ $res.RelPermalink }}" data-sizes="auto" data-src="{{ . }}" alt="featured image" class="lazyload">
</div>
{{ end }}
{{- end -}}
{{ if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
{{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
<div class="post-toc" id="post-toc">
<h2 class="post-toc-title">{{ T "toc" }}</h2>
{{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }}
<div class="post-toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}">
{{ .TableOfContents }}
{{- .TableOfContents -}}
</div>
</div>
<div class="post-toc-mobile" id="post-toc-mobile">
<details>
<summary><div class="post-toc-title"><span>{{ T "toc" }}</span><span><i class="details icon fas fa-angle-down"></i></span></div></summary>
<summary>
<div class="post-toc-title">
<span>{{ T "toc" }}</span>
<span><i class="details icon fas fa-angle-down"></i></span>
</div>
</summary>
<div class="post-toc-content">
{{ $toc := .TableOfContents }}
{{ $toc = replaceRE `id="TableOfContents"` `id="TableOfContentsMobile"` $toc }}
{{ $toc | safeHTML }}
{{- $toc := .TableOfContents -}}
{{- $toc = replaceRE `id="TableOfContents"` `id="TableOfContentsMobile"` $toc -}}
{{- $toc | safeHTML -}}
</div>
</details>
</div>
{{- end }}
{{- end -}}
<div class="post-content">
{{ $content := .Content }}
{{ $REin := `:\(([\w- ]+?)\):` }}
{{ $REout := `<i class="$1 fa-fw"></i>` }}
{{ $content = replaceRE $REin $REout $content }}
{{ $REin = `\[(.+?)\]\^\((.+?)\)` }}
{{ $REout = `<strong><ruby>$1<rt>$2</rt></ruby></strong>` }}
{{ $content = replaceRE $REin $REout $content }}
{{ $REin = `<sup>\[return\]</sup>` }}
{{ $REout = printf "<sup>[%s]</sup>" (T "return") }}
{{ $content = replaceRE $REin $REout $content }}
{{ $REin = `<(h[23456]) (id=".+?")>` }}
{{ $REout = `<a class="post-dummy-target" $2></a><$1>` }}
{{ $content = replaceRE $REin $REout $content }}
{{ $REin = `<(.+) (id="fnref:.+?")>` }}
{{ $REout = `<a class="post-dummy-target" $2></a><$1>` }}
{{ $content = replaceRE $REin $REout $content }}
{{ $content | safeHTML }}
{{- $content := .Content -}}
{{- $REin := `:\(([\w- ]+?)\):` -}}
{{- $REout := `<i class="$1 fa-fw"></i>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `\[(.+?)\]\^\((.+?)\)` -}}
{{- $REout = `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<sup>\[return\]</sup>` -}}
{{- $REout = printf "<sup>[%s]</sup>" (T "return") -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(h[23456]) (id=".+?")>` -}}
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(.+) (id="fnref:.+?")>` -}}
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $content | safeHTML -}}
</div>
{{ partial "post/footer.html" . }}
{{- partial "post/footer.html" . -}}
<div class="post-comment">
{{ if ( .Params.comment | default true ) }}
{{ partial "comments.html" . }}
{{ end }}
{{- if ( .Params.comment | default true ) -}}
{{- partial "comments.html" . -}}
{{- end -}}
</div>
</article>
{{- end }}
{{- end -}}