From daca1fe109da3b57005cfe77c27819f9666c646d Mon Sep 17 00:00:00 2001 From: Hanzei Date: Sun, 1 Jul 2018 10:09:29 +0200 Subject: [PATCH] Use baseof temple to dry code --- layouts/404.html | 37 ++-- layouts/_default/baseof.html | 35 ++++ layouts/_default/list.html | 43 ++-- layouts/_default/single.html | 37 +--- layouts/_default/taxonomy.html | 43 ++-- layouts/_default/terms.html | 32 +-- layouts/blog/list.html | 76 +++---- layouts/blog/single.html | 113 +++++----- layouts/index.html | 195 ++++++++---------- layouts/partials/footer.html | 27 --- layouts/partials/footer/scripts.html | 21 ++ layouts/partials/footer/text.html | 11 + layouts/partials/head/css.html | 15 ++ layouts/partials/head/favicons.html | 2 + layouts/partials/head/metadata.html | 24 +++ layouts/partials/header.html | 64 ------ .../{blogsection.html => home/blog.html} | 0 layouts/partials/{ => home}/projects.html | 23 +-- layouts/partials/{ => home}/social.html | 0 layouts/partials/li.html | 3 - layouts/partials/nav.html | 8 +- layouts/projects/list.html | 67 +++--- layouts/projects/single.html | 14 ++ static/js/index.js | 22 ++ 24 files changed, 399 insertions(+), 513 deletions(-) create mode 100644 layouts/_default/baseof.html delete mode 100644 layouts/partials/footer.html create mode 100644 layouts/partials/footer/scripts.html create mode 100644 layouts/partials/footer/text.html create mode 100644 layouts/partials/head/css.html create mode 100644 layouts/partials/head/favicons.html create mode 100644 layouts/partials/head/metadata.html delete mode 100644 layouts/partials/header.html rename layouts/partials/{blogsection.html => home/blog.html} (100%) rename layouts/partials/{ => home}/projects.html (81%) rename layouts/partials/{ => home}/social.html (100%) delete mode 100644 layouts/partials/li.html create mode 100644 layouts/projects/single.html create mode 100644 static/js/index.js diff --git a/layouts/404.html b/layouts/404.html index c70b17e..a4f98ab 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1,26 +1,13 @@ -{{ partial "header.html" . }} - - -
- -
-

- {{ i18n "404_title" . }} -

+{{ define "title" }} +

{{ i18n "404_title" . }}

+{{ end }} + +{{ define "main" }} +
+ {{ i18n "404_description" . | markdownify }}
- - -
- {{ partial "nav.html" . }} - -
- {{ i18n "404_description" . | markdownify }} -
- -
-
-
-
- {{ partial "footer.html" . }} -
- +{{ end }} + +{{ define "footer" }} + {{ partial "footer/text.html" . }} +{{ end }} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html new file mode 100644 index 0000000..c3f6407 --- /dev/null +++ b/layouts/_default/baseof.html @@ -0,0 +1,35 @@ + + + + {{ block "head" . }} + {{ partial "head/metadata.html" . }} + {{ partial "head/favicons.html" . }} + {{ partial "head/css.html" . }} + {{ end }} + + +
+ +
+ {{ block "title" . }} +

{{ .Title }}

+ {{ end }} +
+ +
+ {{ partial "nav.html" . }} + + {{ block "main" . }} + {{ end }} + + {{ block "footer" . }} + {{ partial "top-icon-with-hr.html" . }} + {{ partial "footer/text.html" . }} + {{ end }} +
+
+ {{ block "js-include" . }} + {{ partial "footer/scripts.html" . }} + {{ end }} + + diff --git a/layouts/_default/list.html b/layouts/_default/list.html index a43cdb6..f102ef5 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,33 +1,16 @@ -{{ partial "header.html" . }} - - -
- -
-

{{ .Title }}

+{{ define "main" }} +
+ {{ .Content }}
- - -
- {{ partial "nav.html" . }} -
- {{ .Content }} -
- -
- -
- - {{ partial "top-icon-with-hr.html" . }} - {{ partial "footer.html" . }} + +
+
- -
- +{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 2c8f5d8..2b7793f 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,32 +1,9 @@ -{{ partial "header.html" . }} - - -
- -
-

{{ .Title }}

+{{ define "main" }} +
+ {{ .Content }}
- - -
- {{ partial "nav.html" . }} - -
- {{ if .Params.image }} -
- {{ .Title }} -
- {{ end }} - {{ .Content }} -
- -
- {{ template "_internal/disqus.html" . }} -
- {{ partial "top-icon-with-hr.html" . }} - {{ partial "footer.html" . }} + +
+ {{ template "_internal/disqus.html" . }}
- -
- - +{{ end }} diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html index 5ce80cd..786676b 100644 --- a/layouts/_default/taxonomy.html +++ b/layouts/_default/taxonomy.html @@ -1,33 +1,18 @@ -{{ partial "header.html" . }} - - -
- -
-

Tagged "{{ lower .Title }}"

-
- - -
- {{ partial "nav.html" . }} +{{ define "title" }} +

Tagged "{{ lower .Title }}"

+{{ end }} + +{{ define "main" }} +
{{ .Content }}
- -
- -
- - {{ partial "top-icon-with-hr.html" . }} - {{ partial "footer.html" . }} +
- -
- - +{{ end }} diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html index ee7ac1f..9a9a796 100644 --- a/layouts/_default/terms.html +++ b/layouts/_default/terms.html @@ -1,30 +1,12 @@ -{{ partial "header.html" . }} - - -
- -
-

{{ .Title }}

-
- - - -
- {{ partial "nav.html" . }} +{{ define "main" }} +
{{ .Content }}
-
-
- {{ range $name, $taxonomy := .Site.Taxonomies.tags }} - {{ lower $name }} ({{ len $taxonomy }}) - {{ end }} -
+
+ {{ range $name, $taxonomy := .Site.Taxonomies.tags }} + {{ lower $name }} ({{ len $taxonomy }}) + {{ end }}
- {{ partial "top-icon-with-hr.html" . }} - {{ partial "footer.html" . }}
- -
- - +{{ end }} diff --git a/layouts/blog/list.html b/layouts/blog/list.html index 9c162f7..fe351b6 100644 --- a/layouts/blog/list.html +++ b/layouts/blog/list.html @@ -1,50 +1,34 @@ -{{ partial "header.html" . }} - - -
- -
-

{{ .Title }}

+{{ define "main" }} +
+ {{ .Content }}
- - -
- {{ partial "nav.html" . }} -
- {{ .Content }} -
- -
- {{ if .Site.Params.showLatest }} -

{{ i18n "index_blog_latestPosts" . }}

- {{ range first 1 .Pages.ByPublishDate.Reverse }} -
{{ .Date.Format (.Site.Params.dateForm | default "Jan 02, 2006") }} -

- - {{ .Title }} - -

-
- {{ .Summary }} - {{ if .Truncated }} - {{ i18n "index_blog_readMore" . }} - {{ end }} -
+
+ {{ if .Site.Params.showLatest }} +

{{ i18n "index_blog_latestPosts" . }}

+ {{ range first 1 .Pages.ByPublishDate.Reverse }} +
{{ .Date.Format (.Site.Params.dateForm | default "Jan 02, 2006") }} +

+ + {{ .Title }} + +

+
+ {{ .Summary }} + {{ if .Truncated }} + {{ i18n "index_blog_readMore" . }} + {{ end }}
- {{ end }} - {{ end }} -

{{ i18n "index_blog_allPosts" . }}

-
    - {{ range .Pages.ByPublishDate.Reverse }} - {{ partial "li.html" . }} - {{ end }} -
- - {{ partial "top-icon-with-hr.html" . }} - {{ partial "footer.html" . }} + {{ end }} + + {{ end }} +

{{ i18n "index_blog_allPosts" . }}

+
    + {{ range .Pages.ByPublishDate.Reverse }} +
  • + {{ .Title }} - {{ .Date.Format (.Site.Params.dateform | default "Jan 02, 2006") }} +
  • + {{ end }} +
- -
- - +{{ end }} diff --git a/layouts/blog/single.html b/layouts/blog/single.html index 6a24536..273dcdc 100644 --- a/layouts/blog/single.html +++ b/layouts/blog/single.html @@ -1,67 +1,52 @@ -{{ partial "header.html" . }} - - -
- -
-

{{ (.Site.GetPage "section" "blog").Title }}

-
- - -
- {{ partial "nav.html" . }} - -
-

- {{ .Title }} -

-
- {{ .Date.Format (.Site.Params.dateForm | default "Jan 02, 2006") }} | - {{ i18n "blog_readingTime" .ReadingTime }} -
- {{ if .Site.Params.shareButtons }} -
- {{ i18n "blog_shareThis" . }}: - {{ if .Site.Params.shareTwitter }} - - {{ end }} - {{ if .Site.Params.shareFacebook }} - - - - - {{ end }} - {{ if .Site.Params.sharePinterest }} - - - - - {{ end }} - {{ if .Site.Params.shareGooglePlus }} - - - - - {{ end }} -
+{{ define "title" }} +

{{ (.Site.GetPage "section" "blog").Title }}

+{{ end }} + +{{ define "main" }} +
+

+ {{ .Title }} +

+
+ {{ .Date.Format (.Site.Params.dateForm | default "Jan 02, 2006") }} | + {{ i18n "blog_readingTime" .ReadingTime }} +
+ {{ if .Site.Params.shareButtons }} +
+ {{ i18n "blog_shareThis" . }}: + {{ if .Site.Params.shareTwitter }} + + {{ end }} + {{ if .Site.Params.shareFacebook }} + + + + + {{ end }} + {{ if .Site.Params.sharePinterest }} + + + + + {{ end }} + {{ if .Site.Params.shareGooglePlus }} + + + + {{ end }}
- - -
- {{ .Content }} -
- -
- {{ template "_internal/disqus.html" . }} -
- {{ partial "top-icon-with-hr.html" . }} - {{ partial "footer.html" . }} + {{ end }}
- -
- - + +
+ {{ .Content }} +
+ +
+ {{ template "_internal/disqus.html" . }} +
+{{ end }} diff --git a/layouts/index.html b/layouts/index.html index 3b8faaf..6d20825 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,110 +1,91 @@ -{{ partial "header.html" . }} - - -
- -
- - -
-
- -

- {{ .Site.Params.firstName | default "Introduction" }}. -

-

- {{ .Site.Params.tagLine }} -

- - -
- {{ partial "social.html" . }} + + + + {{ partial "head/metadata.html" . }} + {{ partial "head/favicons.html" . }} + {{ partial "head/css.html" . }} + + +
+
+ +
+
+ +

+ {{ .Site.Params.firstName | default "Introduction" }}. +

+

+ {{ .Site.Params.tagLine }} +

+ + +
+ {{ partial "home/social.html" . }} +
+ +
+
+
- -
-
- - -
- {{ partial "nav.html" . }} -
-
- - - -
- - -{{ with .Site.GetPage "page" "about" }} -
-
-

{{ .Title }}

-
- {{ if .Site.Params.avatar }} -
- {{ i18n -
- {{ end }} -
- {{.Content}} + + +
+ + {{ partial "nav.html" . }} + {{ with .Site.GetPage "page" "about" }} +
+
+

{{ .Title }}

+
+ {{ if .Site.Params.avatar }} +
+ {{ i18n +
+ {{ end }} +
+ {{.Content}} +
+
+
+ + {{ partial "top-icon.html" . }} +
+

+ + {{ end }} + + {{ partial "home/projects.html" . }} + + {{ partial "home/blog.html" . }} + + {{ with .Site.GetPage "page" "contact" }} +
+
+

{{ .Title }}

+
+ {{.Content}} +
+ {{ if .Site.Params.localTime }} +

{{ i18n "index_currentTime" . }} .

+ {{ end }} + {{ if .Site.Params.email }} +

+ {{ .Site.Params.email }} +

+ {{ end }} + {{ partial "home/social.html" . }} +
+ + {{ partial "top-icon.html" . }} +
+

+ {{ end }} + + {{ partial "footer/text.html" . }}
-
- - {{ partial "top-icon.html" . }} -
- - -

-{{ end }} - - -{{ partial "projects.html" . }} - - -{{ partial "blogsection.html" . }} - - -{{ with .Site.GetPage "page" "contact" }} -
-
-

{{ .Title }}

-
- {{.Content}} -
- - {{ if .Site.Params.localTime }} -

{{ i18n "index_currentTime" . }} .

- - - - - - {{ end }} - - {{ if .Site.Params.email }} -

{{ .Site.Params.email }}

- {{ end }} - - {{ partial "social.html" . }} -
- - {{ partial "top-icon.html" . }} -
- - -

-{{ end }} - - -{{ partial "footer.html" . }} - -
- - - + + {{ partial "footer/scripts.html" . }} + + diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html deleted file mode 100644 index 1668009..0000000 --- a/layouts/partials/footer.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - diff --git a/layouts/partials/footer/scripts.html b/layouts/partials/footer/scripts.html new file mode 100644 index 0000000..5989686 --- /dev/null +++ b/layouts/partials/footer/scripts.html @@ -0,0 +1,21 @@ + + + + + + + +{{ if .Site.Params.localTime }} + + + + +{{ end }} + + +{{ template "_internal/google_analytics_async.html" . }} diff --git a/layouts/partials/footer/text.html b/layouts/partials/footer/text.html new file mode 100644 index 0000000..c356329 --- /dev/null +++ b/layouts/partials/footer/text.html @@ -0,0 +1,11 @@ + diff --git a/layouts/partials/head/css.html b/layouts/partials/head/css.html new file mode 100644 index 0000000..2813437 --- /dev/null +++ b/layouts/partials/head/css.html @@ -0,0 +1,15 @@ + + + + + +{{ if .Site.Params.cacheBuster }} + +{{ else }} + +{{ end }} + + +{{ range .Site.Params.customCSS -}} + +{{- end }} diff --git a/layouts/partials/head/favicons.html b/layouts/partials/head/favicons.html new file mode 100644 index 0000000..c6813e9 --- /dev/null +++ b/layouts/partials/head/favicons.html @@ -0,0 +1,2 @@ + + diff --git a/layouts/partials/head/metadata.html b/layouts/partials/head/metadata.html new file mode 100644 index 0000000..1d97aa2 --- /dev/null +++ b/layouts/partials/head/metadata.html @@ -0,0 +1,24 @@ + + + + + + +{{ if .Site.Params.description }}{{ end }} + +{{ .Title }}{{ if ne .Title .Site.Title }} - {{ .Site.Title }}{{ end }} + + +{{ if .RSSLink }} + +{{ end }} + +{{ if .Site.Params.enforce_ssl }} + +{{ end }} diff --git a/layouts/partials/header.html b/layouts/partials/header.html deleted file mode 100644 index 82ff72b..0000000 --- a/layouts/partials/header.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - -{{ if .Site.Params.description }}{{ end }} - - -{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }} -{{ if eq $url "/" }} - {{ .Site.Title }} -{{ else }} - {{ if .Params.heading }} {{ .Params.heading }} {{ else }} {{ .Title }} {{ end }} -{{ end }} - - - - - -{{ if .Site.Params.enforce_ssl }} - -{{ end }} - - - - - - - - -{{ if .Site.Params.cacheBuster }} - -{{ else }} - -{{ end }} - - -{{ range .Site.Params.customCSS -}} - -{{- end }} - - - - - -{{ template "_internal/google_analytics_async.html" . }} - - -{{ if .RSSLink }} - -{{ end }} - - diff --git a/layouts/partials/blogsection.html b/layouts/partials/home/blog.html similarity index 100% rename from layouts/partials/blogsection.html rename to layouts/partials/home/blog.html diff --git a/layouts/partials/projects.html b/layouts/partials/home/projects.html similarity index 81% rename from layouts/partials/projects.html rename to layouts/partials/home/projects.html index 4a09ca6..8e2c057 100644 --- a/layouts/partials/projects.html +++ b/layouts/partials/home/projects.html @@ -41,8 +41,9 @@
- {{ range $index, $element := .Pages.ByWeight | first $numberOfProjectsToShow }} {{ if not .Params.external_link }} - diff --git a/layouts/partials/social.html b/layouts/partials/home/social.html similarity index 100% rename from layouts/partials/social.html rename to layouts/partials/home/social.html diff --git a/layouts/partials/li.html b/layouts/partials/li.html deleted file mode 100644 index 1e26736..0000000 --- a/layouts/partials/li.html +++ /dev/null @@ -1,3 +0,0 @@ -
  • - {{ .Title }} - {{ .Date.Format (.Site.Params.dateform | default "Jan 02, 2006") }} -
  • diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html index e6cf4c9..f358b9b 100644 --- a/layouts/partials/nav.html +++ b/layouts/partials/nav.html @@ -3,19 +3,19 @@