From 412cc18cf951a5035d4c6cceac5919bf0b71cc70 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Thu, 1 Sep 2016 17:37:27 +0300 Subject: [PATCH] Start using Go 1.6's blocks Partials are nice, but blocks are a better base construct. Right now there is basically only layouts/_default/baseof.html that is doing most of the work. See: https://gohugo.io/templates/blocks --- layouts/_default/baseof.html | 66 +++++++++++++++++++ layouts/_default/list.html | 7 ++ .../content.html => _default/single.html} | 14 +--- layouts/{post => _default}/summary.html | 0 layouts/index.html | 11 ---- layouts/partials/after-footer.html | 3 - layouts/partials/content-summary.html | 14 ---- layouts/partials/footer.html | 5 -- layouts/partials/head.html | 24 ------- layouts/partials/header.html | 6 -- layouts/partials/menu.html | 7 -- layouts/post/single.html | 11 ---- 12 files changed, 76 insertions(+), 92 deletions(-) create mode 100644 layouts/_default/baseof.html rename layouts/{partials/content.html => _default/single.html} (59%) rename layouts/{post => _default}/summary.html (100%) delete mode 100644 layouts/index.html delete mode 100644 layouts/partials/after-footer.html delete mode 100644 layouts/partials/content-summary.html delete mode 100644 layouts/partials/footer.html delete mode 100644 layouts/partials/head.html delete mode 100644 layouts/partials/header.html delete mode 100644 layouts/partials/menu.html delete mode 100644 layouts/post/single.html diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html new file mode 100644 index 0000000..30648f5 --- /dev/null +++ b/layouts/_default/baseof.html @@ -0,0 +1,66 @@ + + + + + + + + {{ "" | safeHTML }} + + {{ if .Site.Params.description }}{{ end }} + {{ if .Site.Params.author }}{{ end }} + + {{ .Hugo.Generator }} + + + + + {{ block "title" . }}{{ .Site.Title }}{{ end }} + + {{ "" | safeHTML }} + + + + + +
+
+ +
+
+ +
+
+

{{ .Site.Title | safeHTML }}

+ {{ if .Site.Params.description }}

{{ .Site.Params.description | safeHTML }}

{{ end }} +
+
+ +
+
+
+ + {{ block "main" . }} + + {{ end }} + +
{{ "" | safeHTML }} + + {{ if not .Site.Params.sidebar.hide }} + {{ partial "sidebar.html" . }} + {{ end }} + +
{{ "" | safeHTML }} +
{{ "" | safeHTML }} + + + + + + diff --git a/layouts/_default/list.html b/layouts/_default/list.html index e69de29..2039ed6 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -0,0 +1,7 @@ +{{ define "main" }} + + {{ range .Data.Pages }} + {{ .Render "summary"}} + {{ end }} + +{{ end }} diff --git a/layouts/partials/content.html b/layouts/_default/single.html similarity index 59% rename from layouts/partials/content.html rename to layouts/_default/single.html index 9c8e4df..f3c8372 100644 --- a/layouts/partials/content.html +++ b/layouts/_default/single.html @@ -1,16 +1,8 @@ -
-
-
+{{ define "title" }}{{ .Title }} – {{ .Site.Title }}{{ end }} +{{ define "main" }} -
- - {{ if not .Site.Params.sidebar.hide }} - {{ partial "sidebar.html" . }} - {{ end }} - -
-
+{{ end }} diff --git a/layouts/post/summary.html b/layouts/_default/summary.html similarity index 100% rename from layouts/post/summary.html rename to layouts/_default/summary.html diff --git a/layouts/index.html b/layouts/index.html deleted file mode 100644 index d4693ff..0000000 --- a/layouts/index.html +++ /dev/null @@ -1,11 +0,0 @@ -{{ partial "head.html" . }} - -{{ partial "menu.html" . }} - -{{ partial "header.html" . }} - -{{ partial "content-summary.html" . }} - -{{ partial "footer.html" . }} - -{{ partial "after-footer.html" . }} diff --git a/layouts/partials/after-footer.html b/layouts/partials/after-footer.html deleted file mode 100644 index 15b9011..0000000 --- a/layouts/partials/after-footer.html +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/layouts/partials/content-summary.html b/layouts/partials/content-summary.html deleted file mode 100644 index 03f88e4..0000000 --- a/layouts/partials/content-summary.html +++ /dev/null @@ -1,14 +0,0 @@ -
-
-
- {{ range .Data.Pages }} - {{ .Render "summary"}} - {{ end }} -
- - {{ if not .Site.Params.sidebar.hide }} - {{ partial "sidebar.html" . }} - {{ end }} - -
-
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html deleted file mode 100644 index ab600b2..0000000 --- a/layouts/partials/footer.html +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/layouts/partials/head.html b/layouts/partials/head.html deleted file mode 100644 index 18784f0..0000000 --- a/layouts/partials/head.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - {{ if .Site.Params.description }}{{ end }} - {{ if .Site.Params.author }}{{ end }} - - {{ .Hugo.Generator }} - - - - - {{ .Title }} - - - - - - diff --git a/layouts/partials/header.html b/layouts/partials/header.html deleted file mode 100644 index 361dbda..0000000 --- a/layouts/partials/header.html +++ /dev/null @@ -1,6 +0,0 @@ -
-
-

{{ .Site.Title | safeHTML }}

- {{ if .Site.Params.description }}

{{ .Site.Params.description | safeHTML }}

{{ end }} -
-
diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html deleted file mode 100644 index ff49965..0000000 --- a/layouts/partials/menu.html +++ /dev/null @@ -1,7 +0,0 @@ -
-
- -
-
diff --git a/layouts/post/single.html b/layouts/post/single.html deleted file mode 100644 index b530878..0000000 --- a/layouts/post/single.html +++ /dev/null @@ -1,11 +0,0 @@ -{{ partial "head.html" . }} - -{{ partial "menu.html" . }} - -{{ partial "header.html" . }} - -{{ partial "content.html" . }} - -{{ partial "footer.html" . }} - -{{ partial "after-footer.html" . }}