feat: new style and faster
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
{{ 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">
|
||||
{{ printf "- %s -" (T "posts") }}
|
||||
</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 }}
|
||||
@@ -1,12 +1,11 @@
|
||||
{{ 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 }}
|
||||
{{ $author := .Site.Author.Name }}
|
||||
{{ if isset .Params "author" }}
|
||||
{{ $author = .Params.author }}
|
||||
{{ $author = .Site.Author.Name }}
|
||||
{{ end }}
|
||||
|
||||
<article class="post-warp">
|
||||
@@ -36,20 +35,16 @@
|
||||
</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">
|
||||
<img src="{{ . }}" 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 ) }}
|
||||
{{ $reAltIn := `<img src="([^"]+)" alt="([^"]+)?" />` }}
|
||||
{{ $reAltOut := "<figure><img src=/images/loading.svg data-sizes=auto data-src=$1 alt=$2 class=lazyload><figcaption class=image-caption>$2</figcaption></figure>" }}
|
||||
{{ $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 ) }}
|
||||
{{ $reAltTitleIn := `<img src="([^"]+)" alt="([^"]+)?" title="([^"]+)?" />` }}
|
||||
{{ $reAltTitleOut := "<figure><img src=/images/loading.svg data-src=$1 data-sizes=auto alt=$2 title=$3 class=lazyload><figcaption class=image-caption>$2</figcaption></figure>" }}
|
||||
{{ $finalContent := $altContent | replaceRE $reAltTitleIn $reAltTitleOut | safeHTML }}
|
||||
{{ $finalContent }}
|
||||
</div>
|
||||
@@ -68,7 +63,7 @@
|
||||
<p class="copyright-item">
|
||||
{{ if and ( $.Param "socialShare" ) (gt (len ($.Param "share")) 0) }}
|
||||
<span>{{ T "share" }}:</span>
|
||||
<span>{{ partial "share-links.html" . }}</span>
|
||||
<span>{{ partial "post/share-links.html" . }}</span>
|
||||
{{ end }}
|
||||
</p>
|
||||
|
||||
|
||||
46
layouts/posts/summary.html
Normal file
46
layouts/posts/summary.html
Normal file
@@ -0,0 +1,46 @@
|
||||
<article class="post" itemscope itemtype="http://schema.org/Article">
|
||||
<header class="post-header">
|
||||
<h1 class="post-title" itemprop="name headline">
|
||||
<a href="{{ .Permalink }}">{{ .Title }}</a>
|
||||
</h1>
|
||||
</header>
|
||||
<div class="post-content">
|
||||
<!--featured_image-->
|
||||
{{ with .Params.featured_image }}
|
||||
<p><img itemprop="image" src={{ . }} class="featured_image"></p>
|
||||
{{ end }}
|
||||
<!-- end featured_image-->
|
||||
{{ .Summary }}
|
||||
</div>
|
||||
<div class="post-footer">
|
||||
<div class="post-meta">
|
||||
<span class="post-time">
|
||||
<time datetime={{.Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} itemprop="datePublished">
|
||||
{{ .Date.Format (.Site.Params.dateFormatToUse | default "2 January 2006") }}
|
||||
</time>
|
||||
</span>
|
||||
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 }}
|
||||
</div>
|
||||
|
||||
{{ with .Params.tags }}
|
||||
<div class="post-tags">
|
||||
{{ range . }}
|
||||
<span class="tag">
|
||||
<a href="{{ "tags/" | absURL }}{{ . | urlize }}/">#{{ . }}</a>
|
||||
</span>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</article>
|
||||
Reference in New Issue
Block a user