From 8c1f7647a16b9f8cd177f555467822c4e0d17937 Mon Sep 17 00:00:00 2001
From: Spencer Brower <6729162+sbrow@users.noreply.github.com>
Date: Mon, 3 Aug 2026 17:07:36 -0400
Subject: [PATCH] refactor: The `
` tag is now configured through a
default partial.
---
TODOS.md | 4 ++--
defaults/layouts/base.html | 2 +-
defaults/layouts/partials/title.html | 1 +
render.odin | 9 ++-------
4 files changed, 6 insertions(+), 10 deletions(-)
create mode 100644 defaults/layouts/partials/title.html
diff --git a/TODOS.md b/TODOS.md
index f6af2ac..4b347bd 100644
--- a/TODOS.md
+++ b/TODOS.md
@@ -1,7 +1,7 @@
## High priority
- Polish existing features before moving on to new ones.
-- [ ] `{{>title}}` default partial? `{{site.title}} | {{ page.title }}`
+- [x] `{{>title}}` default partial? `{{site.title}} | {{ page.title }}`
- [ ] implicit titles (Set when missing?)
- [ ] create a default `head.html`.
- [ ] html comments are rendered, except in minify mode.
@@ -107,7 +107,7 @@
- [ ] Add overloads for every extension - accept ^strings.Builder.
- [ ] Add conventional (Hugo style) footnotes option.
- [ ] Add opt-in deflist support.
-- [ ] Decide if lambdas actually provide any value.
+- [x] Decide if lambdas actually provide any value.
- [ ] add tables extension
- [ ] Peruse [GitHub's](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts)
docs for any juicy nuggets we may have missed.
diff --git a/defaults/layouts/base.html b/defaults/layouts/base.html
index 3edaf64..a2178ad 100644
--- a/defaults/layouts/base.html
+++ b/defaults/layouts/base.html
@@ -4,7 +4,7 @@
- {{title}}
+ {{> title}}
{{> head}}
diff --git a/defaults/layouts/partials/title.html b/defaults/layouts/partials/title.html
new file mode 100644
index 0000000..fef63a3
--- /dev/null
+++ b/defaults/layouts/partials/title.html
@@ -0,0 +1 @@
+{{#site.title}}{{.}}{{#page.title}} | {{/page.title}}{{/site.title}}{{page.title}}
diff --git a/render.odin b/render.odin
index a1bccf9..760e979 100644
--- a/render.odin
+++ b/render.odin
@@ -12,7 +12,6 @@ import "core:time/datetime"
Template_Context :: struct {
now: string,
- title: string,
date_format: string,
timezone: ^datetime.TZ_Region,
og: Open_Graph,
@@ -127,8 +126,8 @@ merge_params :: proc(site, page: json.Value) -> json.Value {
if !ok1 do return page
if !ok2 do return site
merged := make(json.Object, len(site_obj) + len(page_obj), context.temp_allocator)
- for k, v in site_obj { merged[k] = v }
- for k, v in page_obj { merged[k] = v }
+ for k, v in site_obj {merged[k] = v}
+ for k, v in page_obj {merged[k] = v}
return merged
}
@@ -288,7 +287,6 @@ render_page_html :: proc(
seen: ^map[string]bool,
) -> string {
ctx := ctx
- ctx.title = fmt.tprintf("%s | %s", page.title, site.title)
ctx.page = page
ctx.og = og_for_page(site.og, page)
ctx.params = merge_params(site.params, page.params)
@@ -312,7 +310,6 @@ render_home_html :: proc(
}
ctx := ctx
- ctx.title = site.title
ctx.pages = list_pages
ctx.og = og_for_page(site.og, home)
ctx.params = merge_params(site.params, home.params)
@@ -342,14 +339,12 @@ render_section :: proc(
ctx := ctx
if has_index {
ctx.page = section_index
- ctx.title = fmt.tprintf("%s | %s", section_index.title, site.title)
ctx.og = og_for_page(site.og, section_index)
} else {
title := to_title_case(section, alloc)
ctx.page = Page {
title = title,
}
- ctx.title = fmt.tprintf("%s | %s", ctx.page.title, site.title)
ctx.og.title = title
ctx.og.description = ""
ctx.og.url = fmt.tprintf("%s/%s/", site.base_url, section)