chore: Url now stored on page.

This commit is contained in:
Spencer Brower
2026-07-19 12:01:55 -04:00
parent 4fc3eae64c
commit ac43ab1e5a
5 changed files with 21 additions and 11 deletions
+1
View File
@@ -250,6 +250,7 @@ render(tmpl, data, partials) → render_nodes (walks flat node array against con
## Design decisions ## Design decisions
You may never, *ever* remove `TODO:` or `FIXME:` comments. Those are for humans, not machines.
See `HUGO.md` for analysis of why thor doesn't need Hugo's shortcode context isolation. See `HUGO.md` for analysis of why thor doesn't need Hugo's shortcode context isolation.
See `mustache/PARTIAL_INDENT.md` for whitespace handling analysis. See `mustache/PARTIAL_INDENT.md` for whitespace handling analysis.
See `mustache/SPEC.md` for the original implementation specification. See `mustache/SPEC.md` for the original implementation specification.
+9 -3
View File
@@ -1,7 +1,11 @@
- [ ] Integrity hash
- Allows users to verify their output didn't change after upgrading to a new version
- [ ] Content-hash fingerprinting for CSS and JS cache busting - [ ] Content-hash fingerprinting for CSS and JS cache busting
- [ ] Clean up the default layouts - [ ] Clean up the default layouts
- [ ] Memory - [ ] Memory
- [ ] Not sure whether to use temp allocator or site_allocator in opengraph.odin. - [ ] Not sure whether to use temp allocator or site_allocator in opengraph.odin.
- [ ] Not sure whether to use temp allocator or site_allocator in `site_load_content`.
- [ ] Might not need to allocate in `strip_html_tags`
- [ ] Performance - [ ] Performance
- [ ] See if we can disable bounds checks in `write_indented` and elsewhere. - [ ] See if we can disable bounds checks in `write_indented` and elsewhere.
- [ ] Instead of loading the site fresh each time in watch mode, create a - [ ] Instead of loading the site fresh each time in watch mode, create a
@@ -9,16 +13,18 @@
- [ ] Only publish referenced assets. - [ ] Only publish referenced assets.
- [ ] Split `load_page` into frontmatter-parse + body-process phases so draft pages can skip the markdown pipeline entirely - [ ] Split `load_page` into frontmatter-parse + body-process phases so draft pages can skip the markdown pipeline entirely
- [ ] Use spall to find ways to reduce run time. - [ ] Use spall to find ways to reduce run time.
- [ ] mustache data keys for opengraph, etc. - [ ] Open Graph
- [x] mustache data keys for opengraph, etc.
- [ ] OpenGraph meta tags — verify all fields match production site
- [ ] set opengraph tags / description automatically if unset. (Like hugo does)
- [ ] can't set avatar.jpg directly in `og_init`.
- [ ] Author should be a struct adhering to https://schema.org/author - [ ] Author should be a struct adhering to https://schema.org/author
- [ ] Block attributes on code fences (`{ #ex-1 }`) — hello-world.md - [ ] Block attributes on code fences (`{ #ex-1 }`) — hello-world.md
- [ ] include-code shortcode (`{{< include-code ... >}}`) — i-ported-fd-to-odin - [ ] include-code shortcode (`{{< include-code ... >}}`) — i-ported-fd-to-odin
- [ ] follow symlinks in `scan_content`? - [ ] follow symlinks in `scan_content`?
- [ ] ensure sidenote numbers render in display order and not in declaration order. - [ ] ensure sidenote numbers render in display order and not in declaration order.
- [ ] OpenGraph meta tags — verify all fields match production site
- [ ] Add Opt-in deflist support. - [ ] Add Opt-in deflist support.
- [ ] We need to be able to do `Year_Section` in a non-magical, unprivileged way. See [PLAN.md](PLAN.md) for computed properties approach. - [ ] We need to be able to do `Year_Section` in a non-magical, unprivileged way. See [PLAN.md](PLAN.md) for computed properties approach.
- [ ] set opengraph tags / description automatically if unset. (Like hugo does)
- [ ] Table of contents support. - [ ] Table of contents support.
- [ ] prefixing every log message with `thor: ` is silly - [ ] prefixing every log message with `thor: ` is silly
- [ ] Nav items should be active when the current page is selected. - [ ] Nav items should be active when the current page is selected.
+5
View File
@@ -13,6 +13,7 @@ Page :: struct {
slug: string, slug: string,
layout: string, layout: string,
permalink: string, permalink: string,
url: string,
title: string, title: string,
description: string, description: string,
date: string, date: string,
@@ -28,6 +29,10 @@ Page :: struct {
site_load_content :: proc(site: ^Site) { site_load_content :: proc(site: ^Site) {
site.pages = make([dynamic]Page, 0, 8, site_allocator(site)) site.pages = make([dynamic]Page, 0, 8, site_allocator(site))
scan_content(site, site.content_dir, "") scan_content(site, site.content_dir, "")
for &page in site.pages {
page.url = fmt.tprintf("%s%s", site.base_url, page.permalink)
}
} }
// scan_content walks the content directory. At the root level (section=""), // scan_content walks the content directory. At the root level (section=""),
+5 -7
View File
@@ -40,18 +40,16 @@ generate_rss :: proc(site: ^Site) -> string {
fmt.aprintf( fmt.aprintf(
`<item> `<item>
<title>%s</title> <title>%s</title>
<link>%s%s</link> <link>%s</link>
<pubDate>%s</pubDate> <pubDate>%s</pubDate>
<guid>%s%s</guid> <guid>%s</guid>
<description>%s</description> <description>%s</description>
</item> </item>
`, `,
xml_escape(page.title), xml_escape(page.title),
site.base_url, page.url,
page.permalink,
pub_date, pub_date,
site.base_url, page.url,
page.permalink,
xml_escape(page.body_html), xml_escape(page.body_html),
), ),
) )
@@ -78,7 +76,7 @@ generate_sitemap :: proc(site: ^Site) -> string {
} }
strings.write_string( strings.write_string(
&sb, &sb,
fmt.aprintf("<url><loc>%s%s</loc>%s</url>\n", site.base_url, page.permalink, lastmod), fmt.aprintf("<url><loc>%s</loc>%s</url>\n", page.url, lastmod),
) )
} }
+1 -1
View File
@@ -28,7 +28,7 @@ og_init :: proc(site: Site) -> Open_Graph {
og_for_page :: proc(site: Site, page: Page, base: Open_Graph) -> Open_Graph { og_for_page :: proc(site: Site, page: Page, base: Open_Graph) -> Open_Graph {
og := base og := base
is_article := page.section != "" is_article := page.section != ""
og.url = fmt.tprintf("%s%s", site.base_url, page.permalink) og.url = page.url
og.title = strip_html_tags(page.title, context.temp_allocator) og.title = strip_html_tags(page.title, context.temp_allocator)
og.type = "article" if is_article else "website" og.type = "article" if is_article else "website"
og.is_article = is_article og.is_article = is_article