Add include file kind variants
This commit is contained in:
18
README.md
18
README.md
@@ -935,6 +935,8 @@ Body: None.
|
|||||||
|
|
||||||
### Include
|
### Include
|
||||||
|
|
||||||
|
Files can be included in many places in HTML.
|
||||||
|
|
||||||
| If this file exists | It is included at |
|
| If this file exists | It is included at |
|
||||||
| ---------------------------------------------------------| -------------------------------------|
|
| ---------------------------------------------------------| -------------------------------------|
|
||||||
| `yoursite/layouts/partials/paige/body-first.html` | The beginning of the body tag |
|
| `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-first.css` | The beginning of the style tag |
|
||||||
| `yoursite/layouts/partials/paige/style-last.css` | The end 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
|
### Override
|
||||||
|
|
||||||
Most code is in partial templates that the layout templates use.
|
Most code is in partial templates that the layout templates use.
|
||||||
|
@@ -14,32 +14,21 @@
|
|||||||
{{ partial "paige/tag-head.html" $page }}
|
{{ partial "paige/tag-head.html" $page }}
|
||||||
{{ partial "paige/tag-body.html" $page }}
|
{{ partial "paige/tag-body.html" $page }}
|
||||||
|
|
||||||
{{ if templates.Exists "partials/paige/body-first.html" }}
|
{{ partial "paige/func-include.html" (dict "name" "body-first%s.html" "page" $page) }}
|
||||||
{{ partial "paige/body-first.html" $page }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col mt-3" id="paige-site" {{ with $itemAttrs }} {{ $itemAttrs | safeHTMLAttr }} {{ end }}>
|
<div class="col mt-3" id="paige-site" {{ with $itemAttrs }} {{ $itemAttrs | safeHTMLAttr }} {{ end }}>
|
||||||
{{ if templates.Exists "partials/paige/site-first.html" }}
|
{{ partial "paige/func-include.html" (dict "name" "site-first%s.html" "page" $page) }}
|
||||||
{{ partial "paige/site-first.html" $page }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ partial "paige/site-header.html" $page }}
|
{{ partial "paige/site-header.html" $page }}
|
||||||
{{ block "main" $page }}{{ end }}
|
{{ block "main" $page }}{{ end }}
|
||||||
{{ partial "paige/site-footer.html" $page }}
|
{{ partial "paige/site-footer.html" $page }}
|
||||||
|
{{ partial "paige/func-include.html" (dict "name" "site-last%s.html" "page" $page) }}
|
||||||
{{ if templates.Exists "partials/paige/site-last.html" }}
|
|
||||||
{{ partial "paige/site-last.html" $page }}
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ partial "paige/scripts.html" $page }}
|
{{ partial "paige/scripts.html" $page }}
|
||||||
|
{{ partial "paige/func-include.html" (dict "name" "body-last%s.html" "page" $page) }}
|
||||||
{{ if templates.Exists "partials/paige/body-last.html" }}
|
|
||||||
{{ partial "paige/body-last.html" $page }}
|
|
||||||
{{ end }}
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
25
layouts/partials/paige/func-include.html
Normal file
25
layouts/partials/paige/func-include.html
Normal file
@@ -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 }}
|
{{ if or $edit $history $first $last $next $prev }}
|
||||||
<footer class="mw-100" id="paige-page-footer">
|
<footer class="mw-100" id="paige-page-footer">
|
||||||
{{ if $first }}
|
{{ partial "paige/func-include.html" (dict "name" "page-footer-first%s.html" "page" $page) }}
|
||||||
{{ partial "paige/page-footer-first.html" . }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ if or $edit $history }}
|
{{ if or $edit $history }}
|
||||||
<div id="paige-file">
|
<div id="paige-file">
|
||||||
@@ -51,8 +49,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if $last }}
|
{{ partial "paige/func-include.html" (dict "name" "page-footer-last%s.html" "page" $page) }}
|
||||||
{{ partial "paige/page-footer-last.html" . }}
|
|
||||||
{{ end }}
|
|
||||||
</footer>
|
</footer>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@@ -22,9 +22,7 @@
|
|||||||
{{ if or $alert $authors $date $description $first $keywords $last $time $series $title $toc }}
|
{{ if or $alert $authors $date $description $first $keywords $last $time $series $title $toc }}
|
||||||
<header class="mw-100" id="paige-page-header">
|
<header class="mw-100" id="paige-page-header">
|
||||||
<div class="align-items-center d-flex flex-column">
|
<div class="align-items-center d-flex flex-column">
|
||||||
{{ if $first }}
|
{{ partial "paige/func-include.html" (dict "name" "page-header-first%s.html" "page" $page) }}
|
||||||
{{ partial "paige/page-header-first.html" . }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ with $title }}
|
{{ 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>
|
<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>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if $last }}
|
{{ partial "paige/func-include.html" (dict "name" "page-header-last%s.html" "page" $page) }}
|
||||||
{{ partial "paige/page-header-last.html" . }}
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@@ -17,9 +17,7 @@
|
|||||||
|
|
||||||
{{ if or $copyright $credit $first $last $license }}
|
{{ if or $copyright $credit $first $last $license }}
|
||||||
<footer id="paige-site-footer">
|
<footer id="paige-site-footer">
|
||||||
{{ if $first }}
|
{{ partial "paige/func-include.html" (dict "name" "site-footer-first%s.html" "page" $page) }}
|
||||||
{{ partial "paige/site-footer-first.html" . }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ with $copyright }}
|
{{ with $copyright }}
|
||||||
<p class="paige-row-short text-center text-secondary" id="paige-copyright" {{ if $microdata }} itemprop="copyrightNotice" {{ end }}>{{ . }}</p>
|
<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>
|
<p class="paige-row-short text-center text-secondary" id="paige-credit">{{ . }}</p>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if $last }}
|
{{ partial "paige/func-include.html" (dict "name" "site-footer-last%s.html" "page" $page) }}
|
||||||
{{ partial "paige/site-footer-last.html" . }}
|
|
||||||
{{ end }}
|
|
||||||
</footer>
|
</footer>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@@ -34,9 +34,7 @@
|
|||||||
|
|
||||||
{{ if or $breadcrumbs $description $first $last $menu $title }}
|
{{ if or $breadcrumbs $description $first $last $menu $title }}
|
||||||
<header id="paige-site-header">
|
<header id="paige-site-header">
|
||||||
{{ if $first }}
|
{{ partial "paige/func-include.html" (dict "name" "site-header-first%s.html" "page" $page) }}
|
||||||
{{ partial "paige/site-header-first.html" $page }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ with $title }}
|
{{ with $title }}
|
||||||
<div class="display-1 fw-bold {{ if $description }} mb-2 {{ end }} paige-row-tall text-center" id="paige-site-title">{{ . }}</div>
|
<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>
|
</nav>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if $last }}
|
{{ partial "paige/func-include.html" (dict "name" "site-header-last%s.html" "page" $page) }}
|
||||||
{{ partial "paige/site-header-last.html" $page }}
|
|
||||||
{{ end }}
|
|
||||||
</header>
|
</header>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@@ -23,10 +23,7 @@
|
|||||||
{{ $title = delimit $titles " · " }}
|
{{ $title = delimit $titles " · " }}
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
{{ if templates.Exists "partials/paige/head-first.html" }}
|
{{ partial "paige/func-include.html" (dict "name" "head-first%s.html" "page" $page) }}
|
||||||
{{ partial "paige/head-first.html" $page }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ partial "paige/metas.html" $page }}
|
{{ partial "paige/metas.html" $page }}
|
||||||
|
|
||||||
{{ with $title }}
|
{{ with $title }}
|
||||||
@@ -35,8 +32,5 @@
|
|||||||
|
|
||||||
{{ partial "paige/links.html" $page }}
|
{{ partial "paige/links.html" $page }}
|
||||||
{{ partial "paige/style.html" $page }}
|
{{ partial "paige/style.html" $page }}
|
||||||
|
{{ partial "paige/func-include.html" (dict "name" "head-last%s.html" "page" $page) }}
|
||||||
{{ if templates.Exists "partials/paige/head-last.html" }}
|
|
||||||
{{ partial "paige/head-last.html" $page }}
|
|
||||||
{{ end }}
|
|
||||||
</head>
|
</head>
|
||||||
|
Reference in New Issue
Block a user