diff --git a/TODOS.md b/TODOS.md index 2aec1cb..9186c89 100644 --- a/TODOS.md +++ b/TODOS.md @@ -1,5 +1,7 @@ - [ ] Content-hash fingerprinting for CSS and JS cache busting - [ ] Clean up the default layouts +- [ ] Memory + - [ ] Not sure whether to use temp allocator or site_allocator in opengraph.odin. - [ ] Performance - [ ] 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 diff --git a/opengraph.odin b/opengraph.odin index c862495..48b207e 100644 --- a/opengraph.odin +++ b/opengraph.odin @@ -3,38 +3,38 @@ package main import "core:fmt" Open_Graph :: struct { - title: string, - type: string, - image: string, - url: string, - - description: string, - locale: string, - site_name: string, - + title: string, + type: string, + image: string, + url: string, + description: string, + locale: string, + site_name: string, is_article: bool, published_time: string, modified_time: string, section: string, } -og_init :: proc(site: ^Site) -> Open_Graph { +og_init :: proc(site: Site) -> Open_Graph { return { - site_name = site.title, + site_name = site.title, description = site.description, - image = fmt.tprintf("%s/avatar.jpg", site.base_url), - locale = "en_US", + image = fmt.tprintf("%s/avatar.jpg", site.base_url), + locale = "en_US", } } -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 is_article := page.section != "" og.url = fmt.tprintf("%s%s", site.base_url, page.permalink) - og.title = strip_html_tags(page.title) + og.title = strip_html_tags(page.title, context.temp_allocator) og.type = "article" if is_article else "website" og.is_article = is_article og.section = page.section og.published_time = page.date + return og } + diff --git a/render.odin b/render.odin index 5bf737e..dd1a70b 100644 --- a/render.odin +++ b/render.odin @@ -24,12 +24,12 @@ Year_Section :: struct { } Base_Data :: struct { - now: datetime.DateTime, - author: string, - params: json.Value, - body: string, - title: string, - og: Open_Graph, + now: datetime.DateTime, + author: string, + params: json.Value, + body: string, + title: string, + og: Open_Graph, } Page_Data :: struct { @@ -41,13 +41,13 @@ Page_Data :: struct { Home_Data :: struct { using base: Base_Data, - pages: [dynamic]Page_Context, + pages: [dynamic]Page_Context, } Section_Data :: struct { - using base: Base_Data, - page_title: string, - by_year: [dynamic]Year_Section, + using base: Base_Data, + page_title: string, + by_year: [dynamic]Year_Section, } build_page_context :: proc(page: Page) -> Page_Context { @@ -60,8 +60,8 @@ build_page_context :: proc(page: Page) -> Page_Context { } } -strip_html_tags :: proc(s: string) -> string { - sb := strings.builder_make() +strip_html_tags :: proc(s: string, allocator := context.allocator) -> string { + sb := strings.builder_make(allocator) defer strings.builder_destroy(&sb) in_tag := false @@ -117,7 +117,7 @@ get_template :: proc( chain[n] = "base"; n += 1 } - for i in 0..