feat(author): add author_link and fix highlight bug

This commit is contained in:
Dillon
2020-02-01 01:52:27 +08:00
parent 2a7611b5ae
commit 8aa4b6dce6
22 changed files with 136 additions and 110 deletions

View File

@@ -1,13 +1,13 @@
<figure>
<img
{{- $res := resources.Get "svg/loading.svg" | minify -}}
{{ $res := resources.Get "svg/loading.svg" | minify -}}
src="{{ $res.RelPermalink }}"
data-sizes="auto"
data-src="{{ .Destination | safeURL }}"
alt="{{ .Text }}"
{{- with .Title -}}
{{ with .Title -}}
title="{{ . }}"
{{- end -}}
{{ end -}}
class="lazyload"
>
<figcaption class="image-caption">

View File

@@ -1,10 +1,10 @@
<a href="{{ .Destination | safeURL }}"
{{- with .Title -}}
{{ with .Title -}}
title="{{ . }}"
{{- end -}}
{{- if strings.HasPrefix .Destination "http" -}}
{{ end -}}
{{ if strings.HasPrefix .Destination "http" -}}
target="_blank"
{{- end -}}
{{ end -}}
>
{{- .Text -}}
</a>

View File

@@ -17,7 +17,7 @@
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<sup>\[return\]</sup>` -}}
{{- $REout = printf "<sup>[%s]</sup>" (T "return") -}}
{{- $REout = `↩︎` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(h[23456]) (id=".+?")>` -}}
@@ -28,6 +28,10 @@
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<li (id="fn:.+?")(.*?)>\s?<p>` -}}
{{- $REout = `<li $2><p><a class="post-dummy-target" $1></a>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $content | safeHTML -}}
</div>
</div>

View File

@@ -1,9 +1,7 @@
<article class="post" itemscope itemtype="http://schema.org/Article">
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
{{- $author := .Site.Author.name -}}
{{- if isset .Params "author" -}}
{{- $author = .Site.Author.name -}}
{{- end -}}
{{- $author := .Params.author | default .Site.Author.name -}}
{{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}}
<!--featured_image-->
{{- with .Params.featured_image -}}
@@ -19,11 +17,13 @@
</h1>
<div class="post-meta">
<a class="author" href="{{.Site.BaseURL }}" rel="author"><i class="fas fa-user-circle fa-fw"></i>{{ $author }}&nbsp;</a>
<a class="author" href="{{ $author_link }}" rel="author" target="_blank">
<i class="fas fa-user-circle fa-fw"></i>{{ $author }}&nbsp;
</a>
{{ T "publish" }}&nbsp;<time datetime={{ $publish_date }}>{{ $publish_date }}</time>&nbsp;
{{- with .Params.categories -}}
<span class="post-category">
{{- T "included" -}}
{{- T "included" -}}&nbsp;
{{- range . -}}
{{- $name := . -}}
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}}
@@ -41,12 +41,15 @@
</p>
{{- else -}}
{{- $summary := .Summary -}}
{{- $REin := `:\(([\w- ]+?)\):` -}}
{{- $REout := `<i class="$1 fa-fw"></i>` -}}
{{- $summary = replaceRE $REin $REout $summary -}}
{{- $REin = `\[(.+?)\]\^\((.+?)\)` -}}
{{- $REout = `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}}
{{- $summary = replaceRE $REin $REout $summary -}}
{{- $summary | safeHTML -}}
{{- end -}}
</div>
@@ -55,7 +58,9 @@
{{- with .Params.tags -}}
<div class="post-tags">
{{- range . -}}
&nbsp;&nbsp;<span class="tag"><a href="{{ "tags/" | absURL }}{{ . | urlize }}/"><i class="fas fa-tag fa-fw"></i>{{ . }}</a></span>
<span class="tag">
&nbsp;<a href="{{ "tags/" | absURL }}{{ . | urlize }}/"><i class="fas fa-tag fa-fw"></i>&nbsp;{{ . }}</a>
</span>
{{- end -}}
</div>
{{- end -}}