Add include file kind variants

master
Will Faught 5 months ago
parent 49d876e533
commit 598671aab3

@ -935,6 +935,8 @@ Body: None.
### Include
Files can be included in many places in HTML.
| If this file exists | It is included at |
| ---------------------------------------------------------| -------------------------------------|
| `yoursite/layouts/partials/paige/body-first.html` | The beginning of the body tag |
@ -954,6 +956,22 @@ Body: None.
| `yoursite/layouts/partials/paige/style-first.css` | The beginning of the style tag |
| `yoursite/layouts/partials/paige/style-last.css` | The end of the style tag |
There are kind variants of include files that are included only when the file kind matches the page kind.
| If this file exists | It is included when |
| --------------------------------------------------------| ----------------------------|
| `yoursite/layouts/partials/paige/[PLACE]-home.html` | The page kind is "home" |
| `yoursite/layouts/partials/paige/[PLACE]-page.html` | The page kind is "page" |
| `yoursite/layouts/partials/paige/[PLACE]-section.html` | The page kind is "section" |
| `yoursite/layouts/partials/paige/[PLACE]-taxonomy.html` | The page kind is "taxonomy" |
| `yoursite/layouts/partials/paige/[PLACE]-term.html` | The page kind is "term" |
Above, the place placeholder must be "body-first", "body-last", "head-first", etc.
Kind variants are included right after their counterpart non-kind variant.
The argument for the templates is the page.
### Override
Most code is in partial templates that the layout templates use.

@ -14,32 +14,21 @@
{{ partial "paige/tag-head.html" $page }}
{{ partial "paige/tag-body.html" $page }}
{{ if templates.Exists "partials/paige/body-first.html" }}
{{ partial "paige/body-first.html" $page }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "body-first%s.html" "page" $page) }}
<div class="container">
<div class="row">
<div class="col mt-3" id="paige-site" {{ with $itemAttrs }} {{ $itemAttrs | safeHTMLAttr }} {{ end }}>
{{ if templates.Exists "partials/paige/site-first.html" }}
{{ partial "paige/site-first.html" $page }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "site-first%s.html" "page" $page) }}
{{ partial "paige/site-header.html" $page }}
{{ block "main" $page }}{{ end }}
{{ partial "paige/site-footer.html" $page }}
{{ if templates.Exists "partials/paige/site-last.html" }}
{{ partial "paige/site-last.html" $page }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "site-last%s.html" "page" $page) }}
</div>
</div>
</div>
{{ partial "paige/scripts.html" $page }}
{{ if templates.Exists "partials/paige/body-last.html" }}
{{ partial "paige/body-last.html" $page }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "body-last%s.html" "page" $page) }}
</body>
</html>

@ -0,0 +1,25 @@
{{ $params := . }}
{{ $name := $params.name }}
{{ $page := $params.page }}
{{ $partial := print "paige/" (printf $name "") }}
{{ $file := print "partials/" $partial }}
{{ if templates.Exists $file }}
{{ partial $partial $page }}
{{ end }}
{{ range slice "home" "page" "section" "taxonomy" "term" }}
{{ $partial := print "paige/" (printf $name (print "-" .)) }}
{{ $file := print "partials/" $partial }}
{{ $exists := templates.Exists $file }}
{{ $matches := eq $page.Kind . }}
{{ if and $exists $matches }}
{{ partial $partial $page }}
{{ end }}
{{ end }}

@ -19,9 +19,7 @@
{{ if or $edit $history $first $last $next $prev }}
<footer class="mw-100" id="paige-page-footer">
{{ if $first }}
{{ partial "paige/page-footer-first.html" . }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "page-footer-first%s.html" "page" $page) }}
{{ if or $edit $history }}
<div id="paige-file">
@ -51,8 +49,6 @@
</div>
{{ end }}
{{ if $last }}
{{ partial "paige/page-footer-last.html" . }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "page-footer-last%s.html" "page" $page) }}
</footer>
{{ end }}

@ -22,9 +22,7 @@
{{ if or $alert $authors $date $description $first $keywords $last $time $series $title $toc }}
<header class="mw-100" id="paige-page-header">
<div class="align-items-center d-flex flex-column">
{{ if $first }}
{{ partial "paige/page-header-first.html" . }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "page-header-first%s.html" "page" $page) }}
{{ with $title }}
<h1 class="fw-bold" id="paige-page-title" {{ if $microdata }} itemprop="headline name" {{ end }}>{{ if $link }}<a href="{{ $link }}">{{ . }}</a>{{ else }}{{ . }}{{ end }}</h1>
@ -104,9 +102,7 @@
</div>
{{ end }}
{{ if $last }}
{{ partial "paige/page-header-last.html" . }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "page-header-last%s.html" "page" $page) }}
</div>
</header>
{{ end }}

@ -17,9 +17,7 @@
{{ if or $copyright $credit $first $last $license }}
<footer id="paige-site-footer">
{{ if $first }}
{{ partial "paige/site-footer-first.html" . }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "site-footer-first%s.html" "page" $page) }}
{{ with $copyright }}
<p class="paige-row-short text-center text-secondary" id="paige-copyright" {{ if $microdata }} itemprop="copyrightNotice" {{ end }}>{{ . }}</p>
@ -33,8 +31,6 @@
<p class="paige-row-short text-center text-secondary" id="paige-credit">{{ . }}</p>
{{ end }}
{{ if $last }}
{{ partial "paige/site-footer-last.html" . }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "site-footer-last%s.html" "page" $page) }}
</footer>
{{ end }}

@ -34,9 +34,7 @@
{{ if or $breadcrumbs $description $first $last $menu $title }}
<header id="paige-site-header">
{{ if $first }}
{{ partial "paige/site-header-first.html" $page }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "site-header-first%s.html" "page" $page) }}
{{ with $title }}
<div class="display-1 fw-bold {{ if $description }} mb-2 {{ end }} paige-row-tall text-center" id="paige-site-title">{{ . }}</div>
@ -162,8 +160,6 @@
</nav>
{{ end }}
{{ if $last }}
{{ partial "paige/site-header-last.html" $page }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "site-header-last%s.html" "page" $page) }}
</header>
{{ end }}

@ -23,10 +23,7 @@
{{ $title = delimit $titles " · " }}
<head>
{{ if templates.Exists "partials/paige/head-first.html" }}
{{ partial "paige/head-first.html" $page }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "head-first%s.html" "page" $page) }}
{{ partial "paige/metas.html" $page }}
{{ with $title }}
@ -35,8 +32,5 @@
{{ partial "paige/links.html" $page }}
{{ partial "paige/style.html" $page }}
{{ if templates.Exists "partials/paige/head-last.html" }}
{{ partial "paige/head-last.html" $page }}
{{ end }}
{{ partial "paige/func-include.html" (dict "name" "head-last%s.html" "page" $page) }}
</head>

Loading…
Cancel
Save