Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
feat(partial): add hook and image partial
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq committed Feb 3, 2020
1 parent b91ca3d commit 8aba226
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 92 deletions.
10 changes: 8 additions & 2 deletions assets/css/_page/_home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,20 @@
.home-description {
font-size: 1rem;
font-weight: normal;
margin: 0;
padding: .4rem;
}

.home-social-links {
padding-top: .6rem;

i {
font-size: 1.4rem;
font-size: 1.45rem;
}

img {
width: 1.5rem;
height: 1.5rem;
}
}
}
}
13 changes: 2 additions & 11 deletions layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
@@ -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 -}}
Expand Down
9 changes: 1 addition & 8 deletions layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -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>
28 changes: 1 addition & 27 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,7 @@ <h1 class="post-title animated pulse faster">
{{- .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 -}}
18 changes: 4 additions & 14 deletions layouts/_default/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -40,17 +40,7 @@ <h1 class="post-title post-list-title" itemprop="name headline">
{{- .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">
Expand Down
3 changes: 3 additions & 0 deletions layouts/partials/home/social.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
24 changes: 24 additions & 0 deletions layouts/partials/hook/content.html
Original file line number Diff line number Diff line change
@@ -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 -}}
2 changes: 2 additions & 0 deletions layouts/partials/image.html
Original file line number Diff line number Diff line change
@@ -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">
31 changes: 2 additions & 29 deletions layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ <h1 class="post-title animated flipInX">{{ .Title }}</h1>

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

Expand Down Expand Up @@ -70,33 +69,7 @@ <h2 class="post-toc-title">{{ T "toc" }}</h2>
{{- 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" . -}}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Target":"css/style.min.css","MediaType":"text/css","Data":{}}

0 comments on commit 8aba226

Please sign in to comment.