From e980cbedc829381cf6aaab4e9a1cc326c530c076 Mon Sep 17 00:00:00 2001 From: Huy Tran Date: Fri, 27 Jul 2018 08:41:33 +1000 Subject: [PATCH] refactors layouts for head, footer and post --- layouts/_default/list.html | 2 +- layouts/_default/single.html | 10 +++---- layouts/partials/commenting/disqus.html | 25 ---------------- layouts/partials/footer.html | 7 +++-- layouts/partials/footer/deferred-styles.html | 6 ++++ layouts/partials/footer/font-awesome-js.html | 5 +++- .../partials/footer/load-deferred-styles.html | 18 ++++++++++++ layouts/partials/header.html | 4 +-- layouts/partials/header/highlight-css.html | 2 +- layouts/partials/header/styles.html | 3 ++ .../content.html} | 0 .../{ => page-single}/commenting.html | 4 +-- .../page-single/commenting/disqus.html | 29 +++++++++++++++++++ .../commenting/graphcomment.html | 0 .../content.html} | 6 ++-- .../{ => page-single}/post-meta-bottom.html | 0 .../{ => page-single}/post-meta-top.html | 0 .../{ => page-single}/post-related.html | 8 ++--- .../variables-deinit.html} | 0 .../variables-init.html} | 0 layouts/shortcodes/fig.html | 25 ++++++++-------- 21 files changed, 93 insertions(+), 61 deletions(-) delete mode 100644 layouts/partials/commenting/disqus.html create mode 100644 layouts/partials/footer/deferred-styles.html create mode 100644 layouts/partials/footer/load-deferred-styles.html create mode 100644 layouts/partials/header/styles.html rename layouts/partials/{page-list.html => page-list/content.html} (100%) rename layouts/partials/{ => page-single}/commenting.html (53%) create mode 100644 layouts/partials/page-single/commenting/disqus.html rename layouts/partials/{ => page-single}/commenting/graphcomment.html (100%) rename layouts/partials/{page-single.html => page-single/content.html} (58%) rename layouts/partials/{ => page-single}/post-meta-bottom.html (100%) rename layouts/partials/{ => page-single}/post-meta-top.html (100%) rename layouts/partials/{ => page-single}/post-related.html (61%) rename layouts/partials/{page-variables-deinit.html => page-single/variables-deinit.html} (100%) rename layouts/partials/{page-variables-init.html => page-single/variables-init.html} (100%) diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 632ec60..25cbdd5 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -3,7 +3,7 @@ {{- end -}} {{ define "content" -}} - {{ partial "page-list.html" . }} + {{ partial "page-list/content.html" . }} {{- end -}} {{ define "footer" -}} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index cc4f463..eceb1d3 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,17 +1,17 @@ {{ define "header" -}} - {{ partial "page-variables-init.html" . }} + {{ partial "page-single/variables-init.html" . }} {{ partial "header.html" . }} {{- end -}} {{ define "content" -}} - {{ partial "page-single.html" . }} + {{ partial "page-single/content.html" . }} {{- end -}} {{ define "footer" -}}
- {{- partial "highlight-js.html" . -}} - {{- partial "commenting.html" . -}} + {{- partial "page-single/commenting.html" . -}}
+ {{- partial "highlight-js.html" . -}} {{ partial "footer.html" . }} - {{ partial "page-variables-deinit.html" . }} + {{ partial "page-single/variables-deinit.html" . }} {{- end -}} diff --git a/layouts/partials/commenting/disqus.html b/layouts/partials/commenting/disqus.html deleted file mode 100644 index 437a303..0000000 --- a/layouts/partials/commenting/disqus.html +++ /dev/null @@ -1,25 +0,0 @@ -
- - - -comments powered by Disqus diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index c9a9c04..15b942b 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,5 +1,6 @@ -{{ partial "footer/font-awesome-js.html" . }} {{ if (.Site.GoogleAnalytics) -}} - {{ "" | safeHTML }} - {{ template "_internal/google_analytics_async.html" . }} + + {{- template "_internal/google_analytics_async.html" . -}} {{- end }} +{{ partial "footer/font-awesome-js.html" . }} +{{ partial "footer/deferred-styles.html" . }} diff --git a/layouts/partials/footer/deferred-styles.html b/layouts/partials/footer/deferred-styles.html new file mode 100644 index 0000000..f36b1d9 --- /dev/null +++ b/layouts/partials/footer/deferred-styles.html @@ -0,0 +1,6 @@ + diff --git a/layouts/partials/footer/font-awesome-js.html b/layouts/partials/footer/font-awesome-js.html index 0d0c9d0..54f0e72 100644 --- a/layouts/partials/footer/font-awesome-js.html +++ b/layouts/partials/footer/font-awesome-js.html @@ -1 +1,4 @@ - + diff --git a/layouts/partials/footer/load-deferred-styles.html b/layouts/partials/footer/load-deferred-styles.html new file mode 100644 index 0000000..27e949e --- /dev/null +++ b/layouts/partials/footer/load-deferred-styles.html @@ -0,0 +1,18 @@ + diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 03aaa35..c9e6476 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1,9 +1,7 @@ {{ partial "header/meta.html" . }} - {{ partial "header/highlight-css.html" . }} - - + {{ partial "header/styles.html" . }} {{ ` " | safeHTML }} + {{- end -}} {{ if .Site.Params.PygmentsUseClasses -}} diff --git a/layouts/partials/header/styles.html b/layouts/partials/header/styles.html new file mode 100644 index 0000000..700acd5 --- /dev/null +++ b/layouts/partials/header/styles.html @@ -0,0 +1,3 @@ +{{ partial "header/highlight-css.html" . }} + + diff --git a/layouts/partials/page-list.html b/layouts/partials/page-list/content.html similarity index 100% rename from layouts/partials/page-list.html rename to layouts/partials/page-list/content.html diff --git a/layouts/partials/commenting.html b/layouts/partials/page-single/commenting.html similarity index 53% rename from layouts/partials/commenting.html rename to layouts/partials/page-single/commenting.html index e829626..64bcf29 100644 --- a/layouts/partials/commenting.html +++ b/layouts/partials/page-single/commenting.html @@ -1,7 +1,7 @@ {{- if ne .Params.showcomments false -}} {{ if .Site.DisqusShortname -}} - {{- partial "commenting/disqus.html" . -}} + {{- partial "page-single/commenting/disqus.html" . -}} {{- else if .Site.Params.GraphCommentId -}} - {{- partial "commenting/graphcomment.html" . -}} + {{- partial "page-single/commenting/graphcomment.html" . -}} {{- end -}} {{- end }} diff --git a/layouts/partials/page-single/commenting/disqus.html b/layouts/partials/page-single/commenting/disqus.html new file mode 100644 index 0000000..5bb46a2 --- /dev/null +++ b/layouts/partials/page-single/commenting/disqus.html @@ -0,0 +1,29 @@ +
+ + + +comments powered by + Disqus + diff --git a/layouts/partials/commenting/graphcomment.html b/layouts/partials/page-single/commenting/graphcomment.html similarity index 100% rename from layouts/partials/commenting/graphcomment.html rename to layouts/partials/page-single/commenting/graphcomment.html diff --git a/layouts/partials/page-single.html b/layouts/partials/page-single/content.html similarity index 58% rename from layouts/partials/page-single.html rename to layouts/partials/page-single/content.html index 8db6299..4645a30 100644 --- a/layouts/partials/page-single.html +++ b/layouts/partials/page-single/content.html @@ -6,11 +6,11 @@ {{.}} {{ end }} - {{ partial "post-meta-top.html" . }} + {{ partial "page-single/post-meta-top.html" . }}
{{ .Content }}
- {{ partial "post-meta-bottom.html" . }} - {{ partial "post-related.html" . }} + {{ partial "page-single/post-meta-bottom.html" . }} + {{ partial "page-single/post-related.html" . }} diff --git a/layouts/partials/post-meta-bottom.html b/layouts/partials/page-single/post-meta-bottom.html similarity index 100% rename from layouts/partials/post-meta-bottom.html rename to layouts/partials/page-single/post-meta-bottom.html diff --git a/layouts/partials/post-meta-top.html b/layouts/partials/page-single/post-meta-top.html similarity index 100% rename from layouts/partials/post-meta-top.html rename to layouts/partials/page-single/post-meta-top.html diff --git a/layouts/partials/post-related.html b/layouts/partials/page-single/post-related.html similarity index 61% rename from layouts/partials/post-related.html rename to layouts/partials/page-single/post-related.html index 8e27368..7f25ce0 100644 --- a/layouts/partials/post-related.html +++ b/layouts/partials/page-single/post-related.html @@ -1,10 +1,10 @@ +{{ $related := .Site.RegularPages.Related . | first 5 }} +{{ with $related -}}
- {{ $related := .Site.RegularPages.Related . | first 5 }} - {{ with $related }}

Related Articles

- {{ end }} -
\ No newline at end of file + +{{- end }} diff --git a/layouts/partials/page-variables-deinit.html b/layouts/partials/page-single/variables-deinit.html similarity index 100% rename from layouts/partials/page-variables-deinit.html rename to layouts/partials/page-single/variables-deinit.html diff --git a/layouts/partials/page-variables-init.html b/layouts/partials/page-single/variables-init.html similarity index 100% rename from layouts/partials/page-variables-init.html rename to layouts/partials/page-single/variables-init.html diff --git a/layouts/shortcodes/fig.html b/layouts/shortcodes/fig.html index 314bc45..0746971 100644 --- a/layouts/shortcodes/fig.html +++ b/layouts/shortcodes/fig.html @@ -1,22 +1,21 @@ {{ $fig := newScratch }} {{ if .Get "caption" }} - {{ $fig.Set "caption" (.Get "caption") }} + {{ $fig.Set "caption" (.Get "caption") }} {{ else if .Get "alt" }} - {{ $fig.Set "caption" (.Get "alt") }} + {{ $fig.Set "caption" (.Get "alt") }} {{ end }}
- {{ with .Get "link"}}{{ end }} - - {{ with .Get "link"}}{{ end }} - {{ with ($fig.Get "caption") }} + {{ with .Get "link"}}{{ end }} + + {{ with .Get "link"}}{{ end }} + {{ with ($fig.Get "caption") }}
- Figure {{ $.Page.Scratch.Get "fig" }}. {{ . }} + Figure {{ $.Page.Scratch.Get "fig" }}. {{ . }}
- {{ end }} + {{ end }}
{{ .Page.Scratch.Add "fig" 1 }} -{{ $fig.Delete "caption"}} \ No newline at end of file +{{ $fig.Delete "caption"}}