Update post

This commit is contained in:
MeiK
2019-10-22 11:26:50 +08:00
parent 2781d8f60d
commit d4ceb2d60c
4 changed files with 62 additions and 110 deletions

View File

@@ -1,105 +1,3 @@
{{ define "content" -}}
{{ $cdn_url := .Scratch.Get "cdn_url" }}
<article class="post-warp" itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">{{ .Title }}</h1>
<div class="post-meta">
Written by <a itemprop="name" href="{{.Site.BaseURL }}" rel="author">{{ if isset .Params "author" }}{{ .Params.author }}{{ else }}{{ .Site.Params.author }}{{ end }}</a> with ♥
<span class="post-time">
on <time datetime={{.Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} itemprop="datePublished">{{ .Date.Format (.Site.Params.dateFormatToUse | default "January 2, 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>
</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>Author:</span>
<span>{{ . }} </span>
</p>
{{ end }}
{{ with .Permalink }}
<p class="copyright-item">
<span>Link:</span>
<a href={{ . }}>{{ . }}</span>
</p>
{{ end }}
{{ with .Site.Params.license }}
<p class="copyright-item lincese">
{{ . | safeHTML}}
</p>
{{ end }}
</div>
<div class="post-tags">
{{ with .Params.tags }}
<section>
<i class="iconfont icon-tag"></i>Tag(s):
{{ range . }}
<span class="tag"><a href="{{ "tags/" | absURL }}{{ . | urlize }}/">
#{{.}}</a></span>
{{ end }}
</section>
{{ end }}
<section>
<a href="javascript:window.history.back();">back</a></span> ·
<span><a href="{{ .Site.BaseURL }}">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-left"></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-right"></i></a>
{{ end }}
</div>
<div class="post-comment">
{{ if ( .Params.showComments | default true ) }}
{{ if ne .Site.DisqusShortname "" }}
{{ template "_internal/disqus.html" . }}
{{ end }}
{{ end }}
</div>
</article>
{{- end }}
{{ define "content" }}
{{ partial "post.html" .}}
{{end }}

View File

@@ -8,13 +8,13 @@
<a aria-current="page" class="UnderlineNav-item mr-0 mr-md-1 mr-lg-3 selected " href="{{ .Site.BaseURL }}">
Overview
</a>
<a class="UnderlineNav-item mr-0 mr-md-1 mr-lg-3 " href="{{ .Site.BaseURL }}/posts">
<a class="UnderlineNav-item mr-0 mr-md-1 mr-lg-3 " href="{{ .Site.BaseURL }}posts/">
Posts
<span class="Counter hide-lg hide-md hide-sm">
{{ $section_count}}
</span>
</a>
<a class="UnderlineNav-item mr-0 mr-md-1 mr-lg-3 " href="{{ .Site.BaseURL }}/about">
<a class="UnderlineNav-item mr-0 mr-md-1 mr-lg-3 " href="{{ .Site.BaseURL }}about/">
About
</a>
</nav>

View File

@@ -0,0 +1,54 @@
<div class="application-main " data-commit-hovercards-enabled="">
<div itemscope="" itemtype="http://schema.org/SoftwareSourceCode" class="">
<main id="js-repo-pjax-container" data-pjax-container="">
<div class="pagehead repohead instapaper_ignore readability-menu experiment-repo-nav pt-0 pt-lg-4 ">
<div class="repohead-details-container clearfix container-lg p-responsive d-none d-lg-block">
<div class="mb-3 d-flex">
<h1 class="public css-truncate float-none flex-auto width-fit pl-0">
<a class="avatar mr-1" href="{{ .Site.BaseURL }}about/"><img
src="{{ "images/avatar.png" | absURL }}" width="26" height="26"></a>
<span class="author"><a
href="{{ .Site.BaseURL }}about/">{{ .Site.Params.author }}</a></span>
<span class="path-divider">/</span>
<strong itemprop="name" class="css-truncate-target" style="max-width: 410px"><a
href="{{ .URL }}">{{ .Title }}</a></strong>
<div class="d-block text-small text-gray">
Created <time-ago datetime="{{ .PublishDate.Format "2006-01-02" }}" class="no-wrap"
title="Created at {{ .PublishDate.Format "2006/01/02" }}">
{{ .PublishDate.Format "2006-01-02" }}</time-ago>
<span class="file-info-divider"></span>
Modifyd <time-ago datetime="{{ .Lastmod.Format "2006-01-02" }}" class="no-wrap"
title="Modifyd at {{ .Lastmod.Format "2006/01/02" }}">
{{ .Lastmod.Format "2006-01-02" }}</time-ago>
</div>
</h1>
</div>
</div>
</div>
<div class="container-lg clearfix new-discussion-timeline experiment-repo-nav p-responsive">
<div class="repository-content ">
<div class="Box mt-3 position-relative">
<div class="Box-header py-2 d-flex flex-column flex-shrink-0 flex-md-row flex-md-items-center">
<div class="text-mono f6 flex-auto pr-3 flex-order-2 flex-md-order-1 mt-2 mt-md-0">
{{ countwords .Content }} Words
<span class="file-info-divider"></span>
{{ .ReadingTime }} min
</div>
</div>
<div id="readme" class="Box-body readme blob instapaper_body js-code-block-container">
<article class="markdown-body entry-content p-3 p-md-6" itemprop="text">
{{- .Content -}}
</article>
</div>
</div>
</div>
</div>
</main>
</div>
</div>

View File

@@ -11,13 +11,13 @@
<a aria-current="page" class="UnderlineNav-item mr-0 mr-md-1 mr-lg-3 " href="{{ .Site.BaseURL }}">
Overview
</a>
<a class="UnderlineNav-item mr-0 mr-md-1 mr-lg-3 selected" href="{{ .Site.BaseURL }}/posts">
<a class="UnderlineNav-item mr-0 mr-md-1 mr-lg-3 selected" href="{{ .Site.BaseURL }}posts/">
Posts
<span class="Counter hide-lg hide-md hide-sm">
{{ $section_count}}
</span>
</a>
<a class="UnderlineNav-item mr-0 mr-md-1 mr-lg-3 " href="{{ .Site.BaseURL }}/about">
<a class="UnderlineNav-item mr-0 mr-md-1 mr-lg-3 " href="{{ .Site.BaseURL }}about/">
About
</a>
</nav>
@@ -49,7 +49,7 @@
</svg>MIT License
</span>
Updated <relative-time datetime="{{ .PublishDate.Format "2006-01-02" }}" class="no-wrap"
title="Modify at {{ .Lastmod.Format "2006/01/02" }}">
title="Modifyd at {{ .Lastmod.Format "2006/01/02" }}">
{{ .PublishDate.Format "January 2, 2006" }}</relative-time>
</div>
</div>