diff options
| author | tdro <tdro@noreply.example.com> | 2025-03-11 00:00:00 +0000 |
|---|---|---|
| committer | tdro <tdro@noreply.example.com> | 2025-03-11 00:00:00 +0000 |
| commit | 934b0b3c6d5072a9005461a219d089df1f03a099 (patch) | |
| tree | e55e7cf565a32ea4b7d1b6a11c7498c03bbcb972 | |
| parent | e21497c2954ac01f76cb291329cf640c2aea863a (diff) | |
| download | canory-934b0b3c6d5072a9005461a219d089df1f03a099.tar.gz canory-934b0b3c6d5072a9005461a219d089df1f03a099.tar.bz2 canory-934b0b3c6d5072a9005461a219d089df1f03a099.zip | |
config/_default: Support server side includes
| -rw-r--r-- | assets/css/default.css | 2 | ||||
| -rw-r--r-- | config/_default/config.json | 5 | ||||
| -rw-r--r-- | config/_default/config.toml | 2 | ||||
| -rw-r--r-- | config/_default/config.yaml | 2 | ||||
| -rw-r--r-- | themes/default/layouts/partials/author-list.html | 18 | ||||
| -rw-r--r-- | themes/default/layouts/partials/authors.html | 26 | ||||
| -rw-r--r-- | themes/default/layouts/partials/gallery.html | 27 | ||||
| -rw-r--r-- | themes/default/layouts/partials/navigator-right.html | 5 | ||||
| -rw-r--r-- | themes/default/layouts/partials/webfeeds.html | 35 | ||||
| -rw-r--r-- | themes/default/layouts/partials/weblinks.html | 34 |
10 files changed, 101 insertions, 55 deletions
diff --git a/assets/css/default.css b/assets/css/default.css index 9b7cb5c..1510222 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -1853,7 +1853,7 @@ web-links article:not(:last-child) { margin-bottom: 1.5rem; } -web-links aside { +web-links aside:not(:empty) { padding: 1rem; } diff --git a/config/_default/config.json b/config/_default/config.json index 7300cff..a4ef159 100644 --- a/config/_default/config.json +++ b/config/_default/config.json @@ -70,7 +70,10 @@ "production": false, "referrer": "no-referrer", "robots": "index,follow", - "canonical": null + "canonical": null, + "server": { + "includes": false + } }, "webmanifest": { "start_url": "/", diff --git a/config/_default/config.toml b/config/_default/config.toml index 523ddcf..e38d139 100644 --- a/config/_default/config.toml +++ b/config/_default/config.toml @@ -67,6 +67,8 @@ enableRobotsTXT = true production = false referrer = "no-referrer" robots = "index,follow" + [params.site.server] + includes = false [params.webmanifest] start_url = "/" name = "Micro Blog" diff --git a/config/_default/config.yaml b/config/_default/config.yaml index a233931..62d0e1c 100644 --- a/config/_default/config.yaml +++ b/config/_default/config.yaml @@ -56,6 +56,8 @@ params: referrer: no-referrer robots: index,follow canonical: + server: + includes: true webmanifest: start_url: / name: Micro Blog diff --git a/themes/default/layouts/partials/author-list.html b/themes/default/layouts/partials/author-list.html deleted file mode 100644 index 31724e2..0000000 --- a/themes/default/layouts/partials/author-list.html +++ /dev/null @@ -1,18 +0,0 @@ -{{- $authors := print "public/authors.html" -}} - -<author-list> - <h1> - <a data-hover="" href="{{ "authors" | relURL }}/"> - Authors - </a> - </h1> - <aside> - {{- with $authors = resources.Get $authors -}} - {{- $authors.Content | safeHTML -}} - {{- else -}} - <footer> - <code>No items found!</code> - </footer> - {{- end -}} - </aside> -</author-list> diff --git a/themes/default/layouts/partials/authors.html b/themes/default/layouts/partials/authors.html new file mode 100644 index 0000000..040759f --- /dev/null +++ b/themes/default/layouts/partials/authors.html @@ -0,0 +1,26 @@ +{{- $label := "authors.html" -}} +{{- $fragment := print "public/" $label -}} +{{- $footer := printf `<footer><code>No items found!</code></footer>` | safeHTML -}} + +<author-list> + <h1><a data-hover="" href="{{ "authors" | relURL }}/">Authors</a></h1> + <aside> + {{- if site.Params.site.server.includes -}} + + {{- with fileExists $fragment -}} + {{- printf `<!--# include file=%q -->` (print $label | relURL) | safeHTML -}} + {{- else -}} + {{- $footer -}} + {{- end -}} + + {{- else -}} + + {{- with $fragment = resources.Get $fragment -}} + {{- $fragment.Content | safeHTML -}} + {{- else -}} + {{- $footer -}} + {{- end -}} + + {{- end -}} + </aside> +</author-list> diff --git a/themes/default/layouts/partials/gallery.html b/themes/default/layouts/partials/gallery.html index 61d326d..3304c21 100644 --- a/themes/default/layouts/partials/gallery.html +++ b/themes/default/layouts/partials/gallery.html @@ -1,16 +1,27 @@ -{{- $gallery := print "public/" .Section "/gallery.html" -}} +{{- $author := .Section -}} +{{- $label := "gallery.html" -}} +{{- $fragment := print "public/" $author "/" $label -}} +{{- $footer := printf `<footer><code>No items found!</code></footer>` | safeHTML -}} <gallery-images> <h1>Gallery</h1> <aside> - {{- with fileExists $gallery -}} - {{- with resources.Get $gallery -}} - {{- .Content | safeHTML -}} - {{- end -}} + {{- if site.Params.site.server.includes -}} + + {{- with fileExists $fragment -}} + {{- printf `<!--# include file=%q -->` (print $author "/" $label | relURL) | safeHTML -}} {{- else -}} - <footer> - <code>No items found!</code> - </footer> + {{- $footer -}} + {{- end -}} + + {{- else -}} + + {{- with $fragment := resources.Get $fragment -}} + {{- $fragment.Content | safeHTML -}} + {{- else -}} + {{- $footer -}} + {{- end -}} + {{- end -}} </aside> </gallery-images> diff --git a/themes/default/layouts/partials/navigator-right.html b/themes/default/layouts/partials/navigator-right.html index 6933a81..ea62c66 100644 --- a/themes/default/layouts/partials/navigator-right.html +++ b/themes/default/layouts/partials/navigator-right.html @@ -1,7 +1,6 @@ -{{- partial "author-list.html" . -}} - + {{- partial "authors.html" . -}} {{- if (in (slice "page" "section") .Page.Kind) -}} - {{- partial "gallery.html" . -}} + {{- partial "gallery.html" . -}} {{- partial "webfeeds.html" . -}} {{- partial "weblinks.html" . -}} {{- end -}} diff --git a/themes/default/layouts/partials/webfeeds.html b/themes/default/layouts/partials/webfeeds.html index 775e55a..c29d25f 100644 --- a/themes/default/layouts/partials/webfeeds.html +++ b/themes/default/layouts/partials/webfeeds.html @@ -1,10 +1,11 @@ -{{- $count := 0 -}} -{{- $author := partial "function-authors-data.html" . -}} -{{- $feeds := print "public/" .Section "/webfeeds.html" -}} +{{- $count := 0 -}} +{{- $author := .Section -}} +{{- $label := "webfeeds.html" -}} +{{- $fragment := print "public/" $author "/" $label -}} +{{- $authors := partial "function-authors-data.html" . -}} +{{- $footer := printf `<footer><code>No items found!</code></footer>` | safeHTML -}} -{{- with $items := $author.feeds.rss -}} - {{- $count = len $items -}} -{{- end -}} +{{- with $items := $authors.feeds.rss -}} {{- $count = len $items -}} {{- end -}} {{- $expand := cond (gt $count 3) "more" "less" -}} @@ -18,14 +19,22 @@ </summary> </details> <aside> - {{- if and $author.feeds.rss (fileExists $feeds) -}} - {{- with $feeds = resources.Get $feeds -}} - {{- $feeds.Content | safeHTML -}} - {{- end -}} + {{- if site.Params.site.server.includes -}} + + {{- with fileExists $fragment -}} + {{- printf `<!--# include file=%q -->` (print $author "/" $label | relURL) | safeHTML -}} + {{- else -}} + {{- $footer -}} + {{- end -}} + {{- else -}} - <footer> - <code>No items found!</code> - </footer> + + {{- with and $authors.feeds.rss (fileExists $fragment) -}} + {{- with $fragment := resources.Get $fragment -}} {{- $fragment.Content | safeHTML -}} {{- end -}} + {{- else -}} + {{- $footer -}} + {{- end -}} + {{- end -}} </aside> </web-feeds> diff --git a/themes/default/layouts/partials/weblinks.html b/themes/default/layouts/partials/weblinks.html index 9d04d9e..d8ec2e5 100644 --- a/themes/default/layouts/partials/weblinks.html +++ b/themes/default/layouts/partials/weblinks.html @@ -1,15 +1,27 @@ -{{- $author := partial "function-authors-data.html" . -}} -{{- $include := print "public/" .Section "/weblinks.html" -}} +{{- $author := .Section -}} +{{- $label := "weblinks.html" -}} +{{- $fragment := print "public/" $author "/" $label -}} +{{- $authors := partial "function-authors-data.html" . -}} + +{{- $footer := printf `<footer><code>No items found!</code></footer>` | safeHTML -}} <web-links> <h1>Web Links</h1> - {{ if and $author.feeds.rss (fileExists $include) }} - <aside> - {{- (resources.Get $include).Content | safeHTML -}} - </aside> - {{ else }} - <footer> - <code>No items found!</code> - </footer> - {{ end }} + {{- if site.Params.site.server.includes -}} + + {{- with and $authors.feeds.rss (fileExists $fragment) -}} + <aside>{{- printf `<!--# include file=%q -->` (print $author "/" $label | relURL) | safeHTML -}}</aside> + {{- else -}} + {{- $footer -}} + {{- end -}} + + {{- else -}} + + {{- with and $authors.feeds.rss (fileExists $fragment) -}} + <aside>{{- with $fragment := resources.Get $fragment -}} {{- $fragment.Content | safeHTML -}} {{- end -}}</aside> + {{- else -}} + {{- $footer -}} + {{- end -}} + + {{- end -}} </web-links> |
