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,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,15 +1,27 @@
<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
{{ partial "head.html" . }}
<body class="">
<div class="wrapper">
{{ partial "header" . }}
<main class="main">
<div class="container">
{{ block "content" . }}{{ end }}
</div>
</main>
{{ partial "footer.html" . }}
</div>
</body>
<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" . }}
<main class="main">
<div class="container">
{{ block "content" . }}{{ end }}
</div>
</main>
{{ partial "footer.html" . }}
</div>
</body>
</html>

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,8 +1,10 @@
{{ 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>
<div class="post-content">
{{ .Content }}
<div class="post-warp archive">
<h2 class="post-title" style="text-align:right;padding-bottom:2em">{{ .Title }}</h2>
<div class="post-content">
{{ .Content }}
</div>
</div>
</div>
{{end }}
{{end }}

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>
{{ end }}
{{ if .Site.Params.author }}
<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,48 +1,39 @@
<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}}
<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">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<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" . }}
{{ 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 }}
<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}}
<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">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
{{ 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" . }}
{{ partial "seo_schema" . }}

View File

@@ -1,17 +1,19 @@
<nav class="navbar">
<div class="container">
<div class="navbar-header header-logo">
<a href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a>
<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>
{{ end }}
<a href="javascript:void(0);" class="theme-switch"><i class="iconfont icon-sun"></i></a>&nbsp;
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
<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">
@@ -20,12 +22,12 @@
<span></span><span></span><span></span>
</div>
</div>
<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>
{{ end }}
<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 | absLangURL }}" title="{{ .Title }}">{{ .Name }}</a>
{{ end }}
</div>
</div>
</nav>

View File

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

View File

@@ -10,14 +10,14 @@
{{ if .IsPage }}
{{ if $postHasImages }}
<link href="//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 }}
<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 }}
{{ $vendorscript := slice $jquery $prettify $dynamic $main | resources.Concat "/js/vendor_no_gallery.js" | resources.Minify }}
<script src="{{ printf "%s%s" $cdn_url $vendorscript.RelPermalink }}" async=""></script>
{{ end }}
{{ else }}
{{ $main := slice $jquery $main | resources.Concat "/js/vendor_main.js" | resources.Minify}}
<script src="{{ printf "%s%s" $cdn_url $main.RelPermalink }}" async=""></script>

View File

@@ -1,29 +1,31 @@
{{ $pag := $.Paginator }}
{{ if gt $pag.TotalPages 1 }}
<ul class="pagination">
{{ with $pag.First }}
{{ end }}
{{ $.Scratch.Set "__paginator.ellipsed" false }}
{{ range $pag.Pagers }}
{{ $right := sub .TotalPages .PageNumber }}
{{ $showNumber := or (le .PageNumber 1) (eq $right 0) }}
{{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 3)) (lt .PageNumber (add $pag.PageNumber 3))) }}
{{ if $showNumber }}
{{ if gt $pag.TotalPages 1 }}
<ul class="pagination">
{{ with $pag.First }}
{{ end }}
{{ $.Scratch.Set "__paginator.ellipsed" false }}
{{ $.Scratch.Set "__paginator.shouldEllipse" false }}
{{ else }}
{{ $.Scratch.Set "__paginator.shouldEllipse" (not ($.Scratch.Get "__paginator.ellipsed") ) }}
{{ $.Scratch.Set "__paginator.ellipsed" true }}
{{ end }}
{{ if $showNumber }}
<li class="page-item {{ if eq . $pag }}active{{ end }}">
<span class="page-link">
<a href="{{ .URL }}">{{ .PageNumber }}</a></li>
</span>
{{ else if ($.Scratch.Get "__paginator.shouldEllipse") }}
<li class="page-item "><span class="page-link" aria-hidden="true">&hellip;</span></li>
{{ end }}
{{ end }}
</ul>
{{ range $pag.Pagers }}
{{ $right := sub .TotalPages .PageNumber }}
{{ $showNumber := or (le .PageNumber 1) (eq $right 0) }}
{{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 3)) (lt .PageNumber (add $pag.PageNumber 3))) }}
{{ if $showNumber }}
{{ $.Scratch.Set "__paginator.ellipsed" false }}
{{ $.Scratch.Set "__paginator.shouldEllipse" false }}
{{ else }}
{{ $.Scratch.Set "__paginator.shouldEllipse" (not ($.Scratch.Get "__paginator.ellipsed") ) }}
{{ $.Scratch.Set "__paginator.ellipsed" true }}
{{ end }}
{{ if $showNumber }}
<li class="page-item {{ if eq . $pag }}active{{ end }}">
<span class="page-link">
<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 }}
{{ end }}
</ul>
{{ 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,10 +13,10 @@
<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 }}
{{ partial "paginator.html" . }}
</div>
{{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

@@ -3,7 +3,7 @@
<url>
<loc>{{ .Permalink }}</loc>
{{ if not .Lastmod.IsZero }}
<lastmod>{{ safeHTML ( .Lastmod.Format"2006-01-02T15:04:05-07:00" ) }}</lastmod>
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>
{{ end }}
{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>

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 }}