feat: impove i18n and clean code

This commit is contained in:
Dillon ZENG 2019-08-04 21:53:35 +08:00
parent 1e709b5ba4
commit c67a2a86a1
28 changed files with 471 additions and 798 deletions

View file

@ -1,6 +1,7 @@
The MIT License (MIT)
Copyright (c) 2018 LIUZHICHAO.COM
Copyright (c) 2019 DILLONZQ.TOP
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View file

@ -1,20 +0,0 @@
The MIT License (MIT)
Copyright (c) 2018 LIUZHICHAO.COM
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,70 +0,0 @@
# Translations for German
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Single.html
[Written]
other = "Geschrieben"
[by]
other = "durch"
[with]
other = "mit"
[on]
other = "auf"
[in]
other = "im"
[Author]
other = "Autor"
[Words]
other = "Wörter"
[Tag]
other = "Etikett"
[Home]
other = "Hause"
[back]
other = "Zurück"
[minute]
other = "minute"
[Share]
other = "Aktie"
# 404.html
[page]
other = "Seite"
[not]
other = "nicht"
[found]
other = "gefunden"
[return]
other = "Zurückkommen"
[to]
other = "zu"
# Pagination
[More]
other = "Mehr"
# Related post
[Related]
other = "Ähnliche"
[Articles]
other = "Artikel"

View file

@ -1,70 +1,71 @@
# Translations for English
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Single.html
# === Post ===
[posts]
other = "Posts"
# === Post ===
[Written]
other = "Written"
[by]
other = "by"
[with]
other = "with"
[on]
other = "on"
[in]
other = "in"
[Author]
other = "Author"
[Words]
other = "Words"
[Tag]
# === Taxonomy ===
[tag]
other = "Tag"
[Home]
other = "Home"
[tags]
other = "Tags"
[category]
other = "Category"
[categories]
other = "Categories"
# === Taxonomy ===
# === Pagination ===
[More]
other = "More"
# === Pagination ===
# === partials/footer.html ===
[powered]
other = "Powered by %s"
[theme]
other = "Theme - "
# === partials/footer.html ===
# === posts/single.html ===
[wrote]
other = "wrote on"
[wordCount]
other = "about {{ .Count }} words"
[readingTime]
other = "{{ .Count }} min"
[author]
other = "Author"
[lastMod]
other = "Last Modified"
[share]
other = "Share"
[license]
other = "License"
[back]
other = "Back"
[minute]
other = "minute"
[home]
other = "Home"
# === posts/single.html ===
[Share]
other = "Share"
# === 404.html ===
[pageNotFound]
other = "Page not found"
# 404.html
[page]
other = "page"
[not]
other = "not"
[found]
other = "found"
[return]
other = "Return"
[to]
other = "to"
# Pagination
[More]
other = "More"
# Related post
[Related]
other = "Related"
[Articles]
other = "Articles"
[backToHome]
other = "Back to Home"
# === 404.html ===

View file

@ -1,70 +0,0 @@
# Translations for Esperanto
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Single.html
[Written]
other = "Skribita"
[by]
other = "de"
[with]
other = "kun"
[on]
other = "il"
[in]
other = "sur"
[Author]
other = "Aŭtoro"
[Words]
other = "Vortoj"
[Tag]
other = "Tag"
[Home]
other = "Hejmo"
[back]
other = "Reen"
[minute]
other = "minuto"
[Share]
other = "Kunhavigi"
# 404.html
[page]
other = "paĝo"
[not]
other = "ne"
[found]
other = "trovita"
[return]
other = "Revenu"
[to]
other = "al"
# Pagination
[More]
other = "Pli"
# Related post
[Related]
other = "Similaj"
[Articles]
other = "Artikoloj"

View file

@ -1,70 +0,0 @@
# Translations for Spanish
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Single.html
[Written]
other = "Escrito"
[by]
other = "por"
[with]
other = "con"
[on]
other = "en"
[in]
other = "en"
[Author]
other = "Autor"
[Words]
other = "Palabras"
[Tag]
other = "Etiqueta"
[Home]
other = "Casa"
[back]
other = "Atrás"
[minute]
other = "minuto"
[Share]
other = "Compartir"
# 404.html
[page]
other = "página"
[not]
other = "no"
[found]
other = "encontrada"
[return]
other = "Volver"
[to]
other = "a"
# Pagination
[More]
other = "Más"
# Related post
[Related]
other = "Artículos"
[Articles]
other = "Similares"

View file

@ -1,70 +0,0 @@
# Translations for French
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Single.html
[Written]
other = "Écrit"
[by]
other = "par"
[with]
other = "avec"
[on]
other = "sur"
[in]
other = "dans"
[Author]
other = "Auteur"
[Words]
other = "Mots"
[Tag]
other = "Étiquette"
[Home]
other = "Accueil"
[back]
other = "Retour"
[minute]
other = "minute"
[Share]
other = "Partager"
# 404.html
[page]
other = "Page"
[not]
other = "non"
[found]
other = "trouvée"
[return]
other = "Retourner"
[to]
other = "à"
# Pagination
[More]
other = "Plus"
# Related post
[Related]
other = "Articles"
[Articles]
other = "Similaires"

View file

@ -1,71 +0,0 @@
# Translations for Italian
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Single.html
[Written]
other = "Scritto"
[by]
other = "da"
[with]
other = "con"
[on]
other = "il"
[in]
other = "in"
[Author]
other = "Autore"
[Words]
other = "Parole"
[Tag]
other = "Tag"
[Home]
other = "Home"
[back]
other = "Indietro"
[minute]
other = "minuto"
[Share]
other = "Condividi"
# 404.html
[page]
other = "pagina"
[not]
other = "non"
[found]
other = "trovata"
[return]
other = "Torna"
[to]
other = "alla"
# Pagination
[More]
other = "Altro"
# Related post
[Related]
other = "Articoli"
[Articles]
other = "Correlati"

View file

@ -1,71 +0,0 @@
# Translations for Albanian
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Single.html
[Written]
other = "Shkruar"
[by]
other = "nga"
[with]
other = "me"
[on]
other = "në"
[in]
other = "në"
[Author]
other = "Autor"
[Words]
other = "Fjalë"
[Tag]
other = "Etiketë"
[Home]
other = "Shtëpi"
[back]
other = "Prapa"
[minute]
other = "minutë"
[Share]
other = "Pjesë"
# 404.html
[page]
other = "Faqja"
[not]
other = "nuk u"
[found]
other = "gjet"
[return]
other = "Kthehu"
[to]
other = "në"
# Pagination
[More]
other = "më shumë"
# Related post
[Related]
other = "Artikuj"
[Articles]
other = "Të lidhura"

71
i18n/zh.toml Normal file
View file

@ -0,0 +1,71 @@
# Translations for Simplified Chinese
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# === Post ===
[posts]
other = "文章"
# === Post ===
# === Taxonomy ===
[tag]
other = "标签"
[tags]
other = "标签"
[category]
other = "分类"
[categories]
other = "分类"
# === Taxonomy ===
# === Pagination ===
[More]
other = "更多"
# === Pagination ===
# === partials/footer.html ===
[powered]
other = "由 %s 强力驱动"
[theme]
other = "主题 - "
# === partials/footer.html ===
# === posts/single.html ===
[wrote]
other = "创作于"
[wordCount]
other = "约 {{ .Count }} 字"
[readingTime]
other = "预计阅读 {{ .Count }} 分钟"
[author]
other = "作者"
[lastMod]
other = "上次更新"
[share]
other = "内容分享"
[license]
other = "许可协议"
[back]
other = "返回"
[home]
other = "主页"
# === posts/single.html ===
# === 404.html ===
[pageNotFound]
other = "页面没找到"
[backToHome]
other = "回到主页"
# === 404.html ===

View file

@ -1,8 +1,8 @@
{{ define "content" }}
<div class="notfound">
<h1 class="error-emoji"></h1>
<p class="error-text">/* 404 {{ i18n "page" }} {{ i18n "not" }} {{ i18n "found" }}. */</p>
<p class="error-link"><a href="{{ .Site.BaseURL }}">↑ {{ i18n "back" }} {{ i18n "to" }} {{ i18n "Home" }} ↑</a></p>
<p class="error-text">/* 404 {{ T "pageNotFound" }}. */</p>
<p class="error-link"><a href="{{ .Site.BaseURL }}">↑ {{ T "backToHome" }} ↑</a></p>
</div>
<script>
var errorEmojiContainer = document.getElementsByClassName('error-emoji')[0];

View file

@ -1,6 +1,18 @@
<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>{{ block "title" . -}}{{ .Site.Title }}{{- end }}</title>
{{ partial "head.html" . }}
</head>
{{ $cdn_url := ""}}
{{ if eq ( getenv "HUGO_ENV" ) "production" }}
{{ with .Site.Params.cdn_url }}
{{ $cdn_url = .}}
{{ end }}
{{ end }}
{{ .Scratch.Set "cdn_url" $cdn_url }}
<body class="">
<div class="wrapper">
{{ partial "header" . }}

View file

@ -1,18 +0,0 @@
{{ define "content" }}
{{ $data := .Data }}
<div class="post-warp archive">
<h2 class="post-title" style="text-align:right;padding-bottom:2em">-&nbsp;{{ $data.Plural | humanize }}{{ .Title }}&nbsp;-</h2>
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
<h3>{{ .Key }}</h3>
{{ range .Pages }}
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">{{ .Title }}</a>
<span class="archive-item-date">
{{ .Date.Format "2 January 2006" }}
</span>
</article>
{{ end }} {{ end }}
{{ partial "paginator.html" . }}
</div>
{{end }}

View file

@ -1,112 +0,0 @@
{{ define "content" -}}
{{ $cdn_url := .Scratch.Get "cdn_url" }}
<article class="post-warp">
<header class="post-header">
<h1 class="post-title">{{ .Title }}</h1>
<div class="post-meta">
{{ i18n "Written" }} {{ i18n "by" }} <a href="{{.Site.BaseURL }}" rel="author">{{ if isset .Params "author" }}{{ .Params.author }}{{ else }}{{ .Site.Params.author }}{{ end }}</a> {{ i18n "with" }} ♥
<span class="post-time">
{{ i18n "on" }} <time datetime={{.Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} >{{ .Date.Format (.Site.Params.dateFormatToUse | default "2 January 2006") }}</time>
</span>
{{ i18n "in" }}
{{ with .Params.categories -}}
<i class="iconfont icon-folder"></i>
<span class="post-category">
{{ range . }}
{{- $name := . -}}
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}}
<a href="{{ .Permalink }}"> {{ $name }} </a>
{{ end -}}
{{ end }}
</span>
{{- end }}
<i class="iconfont icon-timer"></i>
{{.ReadingTime }} min
</div>
</header>
<div class="post-content">
<!--featured_image-->
{{ $images := findRE "<img src=\"[^\"|\\\"]*\"" .Content -}}
{{ if ge (len $images) 1}}
{{ $.Scratch.Set "postHasImages" true }}
{{ end }}
{{ with .Params.featured_image }}
{{- $img := . -}}
<img src="{{ printf "%s%s" $cdn_url $img }}" class="featured_image">
{{ end }}
<!-- end featured_image-->
{{ $reAltIn := "<img src=\"([^\"]+)\" alt=\"([^\"]+)?\" />" }}
{{ $reAltOut := ( printf "<figure><img src=\"/images/ring.svg\" data-sizes=\"auto\" data-src=\"%s$1\" alt=\"$2\" class=\"lazyload\"><figcaption class=\"image-caption\">$2</figcaption></figure>" $cdn_url ) }}
{{ $altContent := .Content | replaceRE $reAltIn $reAltOut | safeHTML }}
{{ $reAltTitleIn := "<img src=\"([^\"]+)\" alt=\"([^\"]+)?\" title=\"([^\"]+)?\" />" }}
{{ $reAltTitleOut := ( printf "<figure><img src=\"/images/ring.svg\" data-src=\"%s$1\" data-sizes=\"auto\" alt=\"$2\" title=\"$3\" class=\"lazyload\"><figcaption class=\"image-caption\">$2</figcaption></figure>" $cdn_url ) }}
{{ $finalContent := $altContent | replaceRE $reAltTitleIn $reAltTitleOut | safeHTML }}
{{ $finalContent }}
</div>
<div class="post-copyright">
{{ with .Site.Params.author }}
<p class="copyright-item">
<span>{{ i18n "Author" }}:</span>
<span>{{ . }} </span>
</p>
{{ end }}
<p class="copyright-item">
<span>{{ i18n "Words" }}:</span>
<span>{{ .WordCount }}</span>
</p>
<p class="copyright-item">
{{ if and ( $.Param "socialShare" ) (gt (len ($.Param "share")) 0) }}
<span>{{ i18n "Share" }}:</span>
<span>{{ partial "share-links" . }}</span>
{{ end }}
</p>
{{ with .Site.Params.license }}
<p class="copyright-item">
{{ . | safeHTML}}
</p>
{{ end }}
</div>
<div class="post-tags">
{{ with .Params.tags }}
<section>
<i class="iconfont icon-icon-tag"></i>{{ i18n "Tag" }}:
{{ range . }}
<span class="tag">
<a href="{{ "tags/" | absURL }}{{ . | urlize }}/">#{{.}}</a>
</span>
{{ end }}
</section>
{{ end }}
<section>
<a href="javascript:window.history.back();">{{ i18n "back" }}</a></span> ·
<span><a href="{{ .Site.BaseURL }}">{{ i18n "Home" }}</a></span>
</section>
</div>
<div class="post-nav">
{{ if .PrevInSection }}
<a href="{{.PrevInSection.Permalink}}" class="prev" rel="prev" title="{{ .PrevInSection.Title}}"><i class="iconfont icon-dajiantou"></i>&nbsp;{{ .PrevInSection.Title}}</a>
{{ end }}
{{ if .NextInSection }}
<a href="{{.NextInSection.Permalink}}" class="next" rel="next" title="{{.NextInSection.Title}}">{{.NextInSection.Title}}&nbsp;<i class="iconfont icon-xiaojiantou"></i></a>
{{ end }}
</div>
<div class="post-comment">
{{ if ( .Params.showComments | default true ) }}
{{ partial "comments" . }}
{{ end }}
</div>
</article>
{{- end }}

View file

@ -1,47 +0,0 @@
{{ define "content" }}
{{ $termName := .Data.Plural }}
{{ $terms := .Data.Terms.ByCount }}
{{ $length := len $terms }}
{{ $type := .Type }}
<!-- Categories Page -->
<div class="post-warp {{.Data.Plural}}">
<h2 class="post-title" style="text-align:right;padding-bottom:2em">-&nbsp;{{ .Data.Plural | humanize }}&nbsp;-</h2>
{{ if and $.Site.Taxonomies.categories (eq $termName "categories") }}
<div class="categories-card">
{{ range $terms }}
{{ $term := .Term }}
{{ $pages := .Pages }}
{{ with $.Site.GetPage "taxonomy" (printf "%s/%s" $type $term) }}
<div class="card-item">
<div class="categories" >
<a href="{{ .Permalink }}"><h3> <i class="iconfont icon-folder" style="padding-right: 3px"></i> {{ $term | humanize}} </h3> </a>
{{ range first 5 $pages }}
<article class="archive-item">
<a href="{{ .Permalink }}" class="archive-item-link">{{ .Title }}</a>
</article>
{{ end }}
{{ if gt (len $pages) 5 }}
<span class="more-post">
<a href="{{ .Permalink }}" class="more-post-link">{{ i18n "More" }} >></a>
</span>
{{ end }}
</div>
</div>
{{ end }}
{{ end }}
</div> <!-- //categories-card -->
<!-- Tag cloud Page -->
{{ else if and $.Site.Taxonomies.tags (eq $termName "tags") }}
<div class="tag-cloud-tags">
{{ range $.Site.Taxonomies.tags.ByCount }}
{{ if .Name }}
<a href="/tags/{{ .Name | urlize}}/"> {{ .Name }} <small>({{ .Count }})</small></a>
{{ end }}
{{end}}
</div>
{{ end }}
</div>
{{end }}

View file

@ -1,3 +1,5 @@
{{ define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end }}
{{ define "content" }}
<div class="post-warp archive">
<h2 class="post-title" style="text-align:right;padding-bottom:2em">{{ .Title }}</h2>

View file

@ -2,13 +2,14 @@
<div class="copyright">
&copy;
{{ with .Site.Params.since }}
<span itemprop="copyrightYear">{{.}} - {{ now.Year }}</span>
<span itemprop="copyrightYear">{{ if lt . now.Year }}{{ . }} - {{ end }}{{ now.Year }}</span>
{{ end }}
{{ if .Site.Params.author }}
<span class="author" itemprop="copyrightHolder"><a href="{{ .Site.BaseURL }}">{{ .Site.Params.author }}</a> | </span>
<span class="author" itemprop="copyrightHolder"><a href="{{ .Site.BaseURL }}">{{ .Site.Params.author }}</a> |
</span>
{{ end }}
<span>Crafted with ❤️ by <a href="https://github.com/Fastbyte01/KeepIt" target="_blank" rel="external nofollow noopener noreffer">KeepIt</a> & <a href="https://gohugo.io/" target="_blank" rel="external nofollow noopener noreffer">Hugo</a></span>
<span>{{ (printf (T "powered") `<a href="https://gohugo.io/" target="_blank" rel="external nofollow noopener noreffer">Hugo</a>`) | safeHTML }} | {{ T "theme" }}<a href="https://github.com/dillonzq/KeepIt" target="_blank" rel="external nofollow noopener noreffer">KeepIt</a></span>
</div>
</footer>

View file

@ -1,15 +1,26 @@
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp" />
{{ with .Site.Params.google_verification }}<meta name="google-site-verification" content="{{ . }}" />{{ end }}
{{ with .Site.Params.bing_verification }}<meta name="msvalidate.01" content="{{ . }}" />{{end}}
{{ with .Site.Params.yandex_verification }}<meta name="yandex-verification" content="{{ . }}" />{{ end }}
{{ with .Site.Params.pinterest_verification }}<meta name="p:domain_verify" content="{{ . }}"/>{{ end }}
{{ with .Site.Params.baidu_verification }}<meta name=”baidu-site-verification” content="{{ . }}" />{{ end }}
{{ if .PrevInSection }}<link rel="prev" href="{{.PrevInSection.Permalink}}" />{{end}}
{{ if .NextInSection}}<link rel="next" href="{{ .NextInSection.Permalink }}" />{{end}}
{{ with .Site.Params.google_verification }}
<meta name="google-site-verification" content="{{ . }}" />
{{ end }}
{{ with .Site.Params.bing_verification }}
<meta name="msvalidate.01" content="{{ . }}" />
{{end}}
{{ with .Site.Params.yandex_verification }}
<meta name="yandex-verification" content="{{ . }}" />
{{ end }}
{{ with .Site.Params.pinterest_verification }}
<meta name="p:domain_verify" content="{{ . }}" />
{{ end }}
{{ with .Site.Params.baidu_verification }}
<meta name=”baidu-site-verification” content="{{ . }}" />
{{ end }}
{{ if .PrevInSection }}
<link rel="prev" href="{{.PrevInSection.Permalink}}" />
{{ end }}
{{ if .NextInSection}}
<link rel="next" href="{{ .NextInSection.Permalink }}" />
{{end}}
<link rel="canonical" href="{{ .Permalink }}" />
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
@ -19,30 +30,10 @@
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<title>
{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}
{{ if .IsHome }}
{{ .Site.Title }}
{{ else if .Params.heading }}
{{ .Params.heading }}
{{ else }}
{{ .Title }} | {{ .Site.Title }}
{{ end }}
</title>
<meta name="title" content="{{ if .IsHome }}{{ .Site.Title }}{{ else if .Params.heading }}{{ .Params.heading }}{{ else }}{{ .Title }} | {{ .Site.Title }}{{ end}}">
{{ partial "css" . }}
{{ with .OutputFormats.Get "RSS" }}
<link rel="alternate" href="{{ .RelPermalink }}" type="application/rss+xml" title="{{ site.Title }}">
<link rel="feed" href="{{ .RelPermalink }}" type="application/rss+xml" title="{{ site.Title }}">
{{ end }}
{{- template "_internal/twitter_cards.html" . }}
{{ template "_internal/twitter_cards.html" . }}
{{ partial "seo_schema" . }}
</head>
{{ $cdn_url := ""}}
{{ if eq ( getenv "HUGO_ENV" ) "production" }}
{{ with .Site.Params.cdn_url }}
{{ $cdn_url = .}}
{{ end }}
{{ end }}
{{ .Scratch.Set "cdn_url" $cdn_url }}

View file

@ -3,15 +3,17 @@
<div class="navbar-header header-logo">
<a href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a>
</div>
<div class="menu navbar-right">
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
<a class="menu-item{{if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{end}}" href="{{ .URL }}" title="{{ .Title }}">{{ .Name }}</a>
<a class="menu-item{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{ end }}" href="{{ .URL | absLangURL }}" title="{{ .Title }}">{{ .Name }}</a>
{{ end }}
<a href="javascript:void(0);" class="theme-switch"><i class="iconfont icon-sun"></i></a>&nbsp;
</div>
</div>
</nav>
<nav class="navbar-mobile" id="nav-mobile" style="display: none">
<div class="container">
<div class="navbar-header">
@ -24,7 +26,7 @@
<div class="menu" id="mobile-menu">
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
<a class="menu-item{{if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{end}}" href="{{ .URL }}" title="{{ .Title }}">{{ .Name }}</a>
<a class="menu-item{{if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{ end }}" href="{{ .URL | absLangURL }}" title="{{ .Title }}">{{ .Name }}</a>
{{ end }}
</div>
</div>

View file

@ -18,6 +18,5 @@
{{ end }}
<div class="social-links">
{{ partial "social.html" . }}
</div>
</div>

View file

@ -10,7 +10,7 @@
{{ if .IsPage }}
{{ if $postHasImages }}
<link href="//lib.baomitu.com/lightgallery/1.6.12/css/lightgallery.min.css" rel="stylesheet">
<link crossorigin="anonymous" integrity="sha384-yziQACfvCVwLqVFLqkWBYRO3XeA4EqzfXKGwaWnenYn5XzqfJFlFdKEmvutIQdKb" href="https://lib.baomitu.com/lightgallery/1.6.12/css/lightgallery.min.css" rel="stylesheet">
{{ $vendorscript := slice $jquery $lazysizes $prettify $dynamic $main $lihtGallery $lihtGallery_init | resources.Concat "/js/vendor_gallery.js" | resources.Minify }}
<script src="{{ printf "%s%s" $cdn_url $vendorscript.RelPermalink }}" async="" ></script>
{{ else }}

View file

@ -1,4 +1,5 @@
{{ $pag := $.Paginator }}
{{ if gt $pag.TotalPages 1 }}
<ul class="pagination">
{{ with $pag.First }}
@ -19,8 +20,9 @@
{{ if $showNumber }}
<li class="page-item {{ if eq . $pag }}active{{ end }}">
<span class="page-link">
<a href="{{ .URL }}">{{ .PageNumber }}</a></li>
<a href="{{ .URL }}">{{ .PageNumber }}</a>
</span>
</li>
{{ else if ($.Scratch.Get "__paginator.shouldEllipse") }}
<li class="page-item "><span class="page-link" aria-hidden="true">&hellip;</span></li>
{{ end }}

View file

@ -1,7 +1,11 @@
{{ define "title" }}{{ T "posts" }} - {{ .Site.Title }}{{ end }}
{{ define "content" }}
{{ $data := .Data }}
<div class="post-warp archive">
<h2 class="post-title" style="text-align:right;padding-bottom:2em">-&nbsp;{{ $data.Plural | humanize }}{{ .Title }}&nbsp;-</h2>
<h2 class="post-title" style="text-align:right;padding-bottom:2em">
{{- printf "- %s -" (T "posts") -}}
</h2>
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
<h3>{{ .Key }}</h3>
@ -9,7 +13,7 @@
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">{{ .Title }}</a>
<span class="archive-item-date">
{{ .Date.Format "2 January 2006" }}
{{ .Date.Format (.Site.Params.dateFormatToUse | default "01-02") }}
</span>
</article>
{{ end }} {{ end }}

117
layouts/posts/single.html Normal file
View file

@ -0,0 +1,117 @@
{{ define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end }}
{{ define "content" }}
{{ $cdn_url := .Scratch.Get "cdn_url" }}
{{ $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }}
{{ $modify_date := .Lastmod.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }}
{{ $author := .Site.Params.author }}
{{ if isset .Params "author" }}
{{ $author = .Params.author }}
{{ end }}
<article class="post-warp">
<header class="post-header">
<h1 class="post-title">{{ .Title }}</h1>
<div class="post-meta">
<a href="{{.Site.BaseURL }}" rel="author">{{ $author }}</a>
{{ T "wrote" }}
<span class="post-time"><time datetime={{ $publish_date }}>{{ $publish_date }}</time></span>
&nbsp;
{{ T "wordCount" .WordCount }}
<i class="iconfont icon-timer"></i>
{{ T "readingTime" .ReadingTime }}
&nbsp;
{{ with .Params.categories -}}
<span class="post-category">
{{ range . }}
{{- $name := . -}}
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}}
<i class="iconfont icon-folder"></i>
<a href="{{ .Permalink }}">{{ $name }}</a>
{{ end -}}
{{ end }}
</span>
{{- end }}
</div>
</header>
<div class="post-content">
<!--featured_image-->
{{ $images := findRE "<img src=\"[^\"|\\\"]*\"" .Content -}}
{{ if ge (len $images) 1}}
{{ $.Scratch.Set "postHasImages" true }}
{{ end }}
{{ with .Params.featured_image }}
{{ $img := . }}<img src="{{ printf "%s%s" $cdn_url $img }}" class="featured_image">
{{ end }}
<!-- end featured_image-->
{{ $reAltIn := "<img src=\"([^\"]+)\" alt=\"([^\"]+)?\" />" }}
{{ $reAltOut := ( printf "<figure><img src=\"/images/ring.svg\" data-sizes=\"auto\" data-src=\"%s$1\" alt=\"$2\" class=\"lazyload\"><figcaption class=\"image-caption\">$2</figcaption></figure>" $cdn_url ) }}
{{ $altContent := .Content | replaceRE $reAltIn $reAltOut | safeHTML }}
{{ $reAltTitleIn := "<img src=\"([^\"]+)\" alt=\"([^\"]+)?\" title=\"([^\"]+)?\" />" }}
{{ $reAltTitleOut := ( printf "<figure><img src=\"/images/ring.svg\" data-src=\"%s$1\" data-sizes=\"auto\" alt=\"$2\" title=\"$3\" class=\"lazyload\"><figcaption class=\"image-caption\">$2</figcaption></figure>" $cdn_url ) }}
{{ $finalContent := $altContent | replaceRE $reAltTitleIn $reAltTitleOut | safeHTML }}
{{ $finalContent }}
</div>
<div class="post-copyright">
<p class="copyright-item">
<span>{{ T "author" }}:</span>
<span><a href="{{.Site.BaseURL }}" rel="author">{{ $author }}</a></span>
</p>
<p class="copyright-item">
<span>{{ T "lastMod" }}:</span>
<span>{{ $modify_date }}</span>
</p>
<p class="copyright-item">
{{ if and ( $.Param "socialShare" ) (gt (len ($.Param "share")) 0) }}
<span>{{ T "share" }}:</span>
<span>{{ partial "share-links" . }}</span>
{{ end }}
</p>
{{ with .Site.Params.license }}
<p class="copyright-item">
<span>{{ T "license" }}:</span>
<span>{{ . | safeHTML }}</span>
</p>
{{ end }}
</div>
<div class="post-tags">
{{ with .Params.tags }}
<section>
<i class="iconfont icon-icon-tag"></i>{{ T "tag" }}:
{{ range . }}
<span class="tag">
<a href="{{ "tags/" | absURL }}{{ . | urlize }}/">#{{.}}</a>
</span>
{{ end }}
</section>
{{ end }}
<section>
<a href="javascript:window.history.back();">{{ T "back" }}</a></span> ·
<span><a href="{{ .Site.BaseURL }}">{{ T "home" }}</a></span>
</section>
</div>
<div class="post-nav">
{{ if .PrevInSection }}
<a href="{{.PrevInSection.Permalink}}" class="prev" rel="prev" title="{{ .PrevInSection.Title}}"><i
class="iconfont icon-dajiantou"></i>&nbsp;{{ .PrevInSection.Title}}</a>
{{ end }}
{{ if .NextInSection }}
<a href="{{.NextInSection.Permalink}}" class="next" rel="next"
title="{{.NextInSection.Title}}">{{.NextInSection.Title}}&nbsp;<i class="iconfont icon-xiaojiantou"></i></a>
{{ end }}
</div>
<div class="post-comment">
{{ if ( .Params.showComments | default true ) }}
{{ partial "comments" . }}
{{ end }}
</div>
</article>
{{- end }}

View file

@ -0,0 +1,28 @@
{{ define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end }}
{{ define "content" }}
{{ $taxonomy := .Data.Singular }}
{{ $taxonomyName := $taxonomy }}
{{ if eq $taxonomy "tag"}}
{{ $taxonomyName = (T "tag") }}
{{ else if eq $taxonomy "category"}}
{{ $taxonomyName = (T "category") }}
{{ end }}
<div class="post-warp archive">
<h2 class="post-title" style="text-align:right;padding-bottom:2em">
{{- printf "%s - %s" $taxonomyName .Title -}}
</h2>
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
<h3>{{ .Key }}</h3>
{{ range .Pages }}
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">{{ .Title }}</a>
<span class="archive-item-date">
{{ .Date.Format (.Site.Params.dateFormatToUse | default "01-02") }}
</span>
</article>
{{ end }}
{{ end }}
{{ partial "paginator.html" . }}
</div>
{{end }}

View file

@ -0,0 +1,61 @@
{{ define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end }}
{{ define "content" }}
{{ $taxonomy := .Data.Singular }}
{{ $taxonomysName := $taxonomy }}
{{ if eq $taxonomy "tag"}}
{{ $taxonomysName = (T "tags") }}
{{ else if eq $taxonomy "category"}}
{{ $taxonomysName = (T "categories") }}
{{ end }}
{{ $terms := .Data.Terms.ByCount }}
{{ $length := len $terms }}
{{ $type := .Type }}
<div class="post-warp {{.Data.Plural}}">
<h2 class="post-title" style="text-align:right;padding-bottom:2em">
{{- printf "- %s -" $taxonomysName -}}
</h2>
<!-- Categories Page -->
{{ if eq $taxonomy "category" }}
<div class="categories-card">
{{ range $terms }}
{{ $term := .Term }}
{{ $pages := .Pages }}
{{ with $.Site.GetPage "taxonomy" (printf "%s/%s" $type $term) }}
<div class="card-item">
<div class="categories">
<a href="{{ .Permalink }}">
<h3> <i class="iconfont icon-folder" style="padding-right: 3px"></i> {{ $term | humanize}} </h3>
</a>
{{ range first 5 $pages }}
<article class="archive-item">
<a href="{{ .Permalink }}" class="archive-item-link">{{ .Title }}</a>
</article>
{{ end }}
{{ if gt (len $pages) 5 }}
<span class="more-post">
<a href="{{ .Permalink }}" class="more-post-link">{{ T "More" }} >></a>
</span>
{{ end }}
</div>
</div>
{{ end }}
{{ end }}
</div>
<!-- Tag Cloud Page -->
{{ else if eq $taxonomy "tag" }}
<div class="tag-cloud-tags">
{{ range $.Site.Taxonomies.tags.ByCount }}
{{ if .Name }}
<a href="/tags/{{ .Name | urlize}}/"> {{ .Name }} <small>({{ .Count }})</small></a>
{{ end }}
{{end}}
</div>
{{ end }}
</div>
{{end }}