From 246a650445682eb88b1a2548c1d7e83a0463d55e Mon Sep 17 00:00:00 2001 From: Will Faught Date: Thu, 26 Jan 2023 17:43:56 -0800 Subject: [PATCH] First, last includes for body, footer, head, header, and main tags --- README.md | 18 ++++++++++++++++-- layouts/_default/baseof.html | 9 +++++++++ layouts/partials/paige/footer.html | 23 +++++++++++++++++------ layouts/partials/paige/head.html | 3 +++ layouts/partials/paige/header.html | 16 ++++++++++++++-- 5 files changed, 59 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a1dde564..1f97db83 100644 --- a/README.md +++ b/README.md @@ -767,8 +767,22 @@ Parameters: ## Customize -If `partials/paige/head-last.html` exists in the site, it is included at the end of the head tag. -If `partials/paige/body-last.html` exists in the site, it is included at the end of the body tag. +### Include + +| If this file exists in the site | It is included at | +| ------------------------------- | ----------------- | +| `partials/paige/body-first.html` | The beginning of the body tag | +| `partials/paige/body-last.html` | The end of the body tag | +| `partials/paige/footer-first.html` | The beginning of the footer tag | +| `partials/paige/footer-last.html` | The end of the footer tag | +| `partials/paige/head-first.html` | The beginning of the head tag | +| `partials/paige/head-last.html` | The end of the head tag | +| `partials/paige/header-first.html` | The beginning of the header tag | +| `partials/paige/header-last.html` | The end of the header tag | +| `partials/paige/main-first.html` | The beginning of the main tag | +| `partials/paige/main-last.html` | The end of the main tag | + +### Override Most code is in partial templates that are included by the default layouts. Elements can be added, changed, or removed easily by overriding the corresponding default layout or partial template. diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 7940ab08..770b0542 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -4,12 +4,21 @@ {{ partial "paige/head.html" . }} {{ partial "paige/body.html" . }} + {{ if templates.Exists "partials/paige/body-first.html" }} + {{ partial "paige/body-first.html" . }} + {{ end }}
{{ partial "paige/header.html" . }}
+ {{ if templates.Exists "partials/paige/main-first.html" }} + {{ partial "paige/main-first.html" . }} + {{ end }} {{ block "main" . }}{{ end }} + {{ if templates.Exists "partials/paige/main-last.html" }} + {{ partial "paige/main-last.html" . }} + {{ end }}
{{ partial "paige/footer.html" . }}
diff --git a/layouts/partials/paige/footer.html b/layouts/partials/paige/footer.html index 154986f7..1faa1458 100644 --- a/layouts/partials/paige/footer.html +++ b/layouts/partials/paige/footer.html @@ -1,11 +1,22 @@ -{{ if or .Site.Copyright (not .Site.Params.paige.hide_theme_link) }} +{{ $copyright := .Site.Copyright }} +{{ $first := templates.Exists "partials/paige/footer-first.html" }} +{{ $last := templates.Exists "partials/paige/footer-last.html" }} +{{ $showlink := not .Site.Params.paige.hide_theme_link }} + +{{ if or $copyright $first $last $showlink }}
- {{ if and .Site.Copyright (not .Site.Params.paige.hide_theme_link) }} -

{{ .Site.Copyright | markdownify }} · Paige Theme

- {{ else if .Site.Copyright }} -

{{ .Site.Copyright | markdownify }}

- {{ else if not .Site.Params.paige.hide_theme_link }} + {{ if $first }} + {{ partial "paige/footer-first.html" . }} + {{ end }} + {{ if and $copyright $showlink }} +

{{ $copyright | markdownify }} · Paige Theme

+ {{ else if $copyright }} +

{{ $copyright | markdownify }}

+ {{ else if $showlink }}

Paige Theme

{{ end }} + {{ if $last }} + {{ partial "paige/footer-last.html" . }} + {{ end }}
{{ end }} diff --git a/layouts/partials/paige/head.html b/layouts/partials/paige/head.html index edffbc32..2e23d52f 100644 --- a/layouts/partials/paige/head.html +++ b/layouts/partials/paige/head.html @@ -1,4 +1,7 @@ + {{ if templates.Exists "partials/paige/head-first.html" }} + {{ partial "paige/head-first.html" . }} + {{ end }} {{ partial "paige/metas.html" . }} {{ partial "paige/func-title.html" . }} {{ partial "paige/links.html" . }} diff --git a/layouts/partials/paige/header.html b/layouts/partials/paige/header.html index 626a78be..69247f17 100644 --- a/layouts/partials/paige/header.html +++ b/layouts/partials/paige/header.html @@ -1,5 +1,17 @@ -{{ if .Site.Menus.main }} +{{ $first := templates.Exists "partials/paige/header-first.html" }} +{{ $last := templates.Exists "partials/paige/header-last.html" }} +{{ $menu := .Site.Menus.main }} + +{{ if or $first $last $menu }}
- {{ partial "paige/menu.html" . }} + {{ if $first }} + {{ partial "paige/header-first.html" . }} + {{ end }} + {{ if $menu }} + {{ partial "paige/menu.html" . }} + {{ end }} + {{ if $last }} + {{ partial "paige/header-last.html" . }} + {{ end }}
{{ end }}