feat(partial): add hook and image partial

This commit is contained in:
Dillon 2020-02-03 11:46:30 +08:00
parent b91ca3d61a
commit 8aba226290
12 changed files with 52 additions and 92 deletions

View file

@ -36,6 +36,7 @@
.home-description {
font-size: 1rem;
font-weight: normal;
margin: 0;
padding: .4rem;
}
@ -43,7 +44,12 @@
padding-top: .6rem;
i {
font-size: 1.4rem;
font-size: 1.45rem;
}
img {
width: 1.5rem;
height: 1.5rem;
}
}
}
}

View file

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

View file

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

View file

@ -6,33 +6,7 @@
{{- .Title -}}
</h1>
<div class="post-content">
{{- $content := .Content -}}
{{- $REin := `:\(([\w- ]+?)\):` -}}
{{- $REout := `<i class="$1 fa-fw"></i>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `\[(.+?)\]\^\((.+?)\)` -}}
{{- $REout = `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<sup>\[return\]</sup>` -}}
{{- $REout = `↩︎` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(h[23456]) (id=".+?")>` -}}
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(.+) (id="fnref:.+?")>` -}}
{{- $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 -}}
{{- partial "hook/content.html" .Content | safeHTML -}}
</div>
</div>
{{- end -}}

View file

@ -5,13 +5,13 @@
<!--featured_image-->
{{- with .Params.featured_image -}}
{{- $image := $.Params.featured_image_preview | default . -}}
<div class="post-featured-image-preview">
{{- $res := resources.Get "svg/loading.svg" | minify -}}
<img src="{{ $res.RelPermalink }}" data-sizes="auto" data-src="{{ $image }}" alt="featured image" class="lazyload">
{{- $image := $.Params.featured_image_preview | default . -}}
{{- partial "image" $image -}}
</div>
{{- end -}}
<!-- end featured_image-->
<h1 class="post-title post-list-title" itemprop="name headline">
<a href="{{ .Permalink }}">{{ .Title }}</a>
</h1>
@ -40,17 +40,7 @@
{{- .Params.description -}}
</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 -}}
{{- partial "hook/content.html" .Summary | safeHTML -}}
{{- end -}}
</div>
<div class="post-footer">

View file

@ -282,4 +282,7 @@
<a href="mailto:{{ . }}" rel="me noopener noreffer">
<i class="far fa-envelope fa-fw" target="_blank" title="Email"></i>
</a>
{{- end -}}
{{- with .Site.Params.Social.Custom}}
{{- . | safeHTML -}}
{{- end -}}

View file

@ -0,0 +1,24 @@
{{- $REin := `:\(([\w- ]+?)\):` -}}
{{- $REout := `<i class="$1 fa-fw"></i>` -}}
{{- $content := replaceRE $REin $REout . -}}
{{- $REin = `\[(.+?)\]\^\((.+?)\)` -}}
{{- $REout = `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<sup>\[return\]</sup>` -}}
{{- $REout = `↩︎` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(h[23456]) (id=".+?")>` -}}
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(.+) (id="fnref:.+?")>` -}}
{{- $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>` -}}
{{- return replaceRE $REin $REout $content -}}

View file

@ -0,0 +1,2 @@
{{- $res := resources.Get "svg/loading.svg" | minify -}}
<img src="{{ $res.RelPermalink }}" data-sizes="auto" data-src="{{ . }}" alt="featured image" class="lazyload">

View file

@ -39,8 +39,7 @@
{{- with .Params.featured_image -}}
<div class="post-featured-image">
{{- $res := resources.Get "svg/loading.svg" | minify -}}
<img src="{{ $res.RelPermalink }}" data-sizes="auto" data-src="{{ . }}" alt="featured image" class="lazyload">
{{- partial "image" . -}}
</div>
{{- end -}}
@ -70,33 +69,7 @@
{{- end -}}
<div class="post-content">
{{- $content := .Content -}}
{{- $REin := `:\(([\w- ]+?)\):` -}}
{{- $REout := `<i class="$1 fa-fw"></i>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `\[(.+?)\]\^\((.+?)\)` -}}
{{- $REout = `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<sup>\[return\]</sup>` -}}
{{- $REout = `↩︎` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(h[23456]) (id=".+?")>` -}}
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(.+?) (id="fnref:.+?")>` -}}
{{- $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 -}}
{{- partial "hook/content.html" .Content | safeHTML -}}
</div>
{{- partial "post/footer.html" . -}}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{"Target":"css/style.min.css","MediaType":"text/css","Data":{}}