diff --git a/content.odin b/content.odin
index a14ed1e..1631d57 100644
--- a/content.odin
+++ b/content.odin
@@ -20,7 +20,7 @@ Page :: struct {
date: string,
lastmod: string,
menu: string,
- body_html: string,
+ content: string,
og: Open_Graph,
draft: bool,
is_starred: bool,
@@ -52,7 +52,13 @@ site_load_content :: proc(site: ^Site) {
// Phase 3: Load pages (grammars already cached)
for file in pending {
- page, ok := load_page(file.path, file.section, file.slug, file.is_index, site.markdown_extensions)
+ page, ok := load_page(
+ file.path,
+ file.section,
+ file.slug,
+ file.is_index,
+ site.markdown_extensions,
+ )
if ok && (!page.draft || .Drafts in site.features) {
append(&site.pages, page)
}
@@ -85,12 +91,15 @@ scan_content_files :: proc(dir: string, section: string, pending: ^[dynamic]Pend
is_idx := filename == "index"
slug := is_idx ? "" : filename
- append(pending, Pending_File {
- path = strings.clone(entry.fullpath, context.temp_allocator),
- section = section,
- slug = slug,
- is_index = is_idx,
- })
+ append(
+ pending,
+ Pending_File {
+ path = strings.clone(entry.fullpath, context.temp_allocator),
+ section = section,
+ slug = slug,
+ is_index = is_idx,
+ },
+ )
case .Directory:
if section == "" {
@@ -101,12 +110,15 @@ scan_content_files :: proc(dir: string, section: string, pending: ^[dynamic]Pend
index_path = fmt.tprintf("%s/index.md", entry.fullpath)
}
if os.exists(index_path) {
- append(pending, Pending_File {
- path = strings.clone(index_path, context.temp_allocator),
- section = section,
- slug = entry.name,
- is_index = false,
- })
+ append(
+ pending,
+ Pending_File {
+ path = strings.clone(index_path, context.temp_allocator),
+ section = section,
+ slug = entry.name,
+ is_index = false,
+ },
+ )
}
}
case .Undetermined, .Symlink, .Named_Pipe, .Socket, .Block_Device, .Character_Device:
@@ -140,8 +152,9 @@ collect_languages :: proc(files: []Pending_File) -> []string {
i += 1
}
- if i + 3 <= len(line) && (line[i] == '`' && line[i+1] == '`' && line[i+2] == '`') ||
- (i + 3 <= len(line) && line[i] == '~' && line[i+1] == '~' && line[i+2] == '~') {
+ if i + 3 <= len(line) &&
+ (line[i] == '`' && line[i + 1] == '`' && line[i + 2] == '`') ||
+ (i + 3 <= len(line) && line[i] == '~' && line[i + 1] == '~' && line[i + 2] == '~') {
fence_char := line[i]
j := i + 3
for j < len(line) && line[j] == fence_char {
@@ -226,9 +239,9 @@ load_page :: proc(
page.og = fm.og
if strings.has_suffix(file_path, ".html") {
- page.body_html = strings.clone(body)
+ page.content = strings.clone(body)
} else {
- page.body_html = md.process(body, ext, file_path)
+ page.content = md.process(body, ext, file_path)
}
if section == "" && is_index {
@@ -256,3 +269,4 @@ strip_extension :: proc(name: string) -> string {
}
return name[:dot]
}
+
diff --git a/feed.odin b/feed.odin
index bc22c95..57e5b34 100644
--- a/feed.odin
+++ b/feed.odin
@@ -50,7 +50,7 @@ generate_rss :: proc(site: ^Site) -> string {
page.url,
pub_date,
page.url,
- xml_escape(page.body_html),
+ xml_escape(page.content),
),
)
}
@@ -74,10 +74,7 @@ generate_sitemap :: proc(site: ^Site) -> string {
if page.date != "" {
lastmod = fmt.aprintf("%s", page.date)
}
- strings.write_string(
- &sb,
- fmt.aprintf("%s%s\n", page.url, lastmod),
- )
+ strings.write_string(&sb, fmt.aprintf("%s%s\n", page.url, lastmod))
}
// Section index pages (for sections without an index in content)
diff --git a/opengraph.odin b/opengraph.odin
index 7a88007..8186f23 100644
--- a/opengraph.odin
+++ b/opengraph.odin
@@ -70,8 +70,8 @@ og_for_page :: proc(site_og: Open_Graph, page: Page) -> Open_Graph {
og.description = page.description
description_set = true
}
- if !description_set && is_article && page.body_html != "" {
- og.description = generate_description(generate_summary(page.body_html))
+ if !description_set && is_article && page.content != "" {
+ og.description = generate_description(generate_summary(page.content))
description_set = true
}
if !description_set {
@@ -115,3 +115,4 @@ og_for_page :: proc(site_og: Open_Graph, page: Page) -> Open_Graph {
return og
}
+
diff --git a/render.odin b/render.odin
index 316cc1c..40e8d84 100644
--- a/render.odin
+++ b/render.odin
@@ -269,7 +269,7 @@ render_page_html :: proc(
ctx := ctx
ctx.title = fmt.tprintf("%s | %s", page.title, site.title)
ctx.page_title = page.title
- ctx.content = page.body_html
+ ctx.content = page.content
ctx.date = page.date
ctx.og = og_for_page(site.og, page)
return render_template(content_tpl, ctx, partials)
@@ -293,7 +293,7 @@ render_home_html :: proc(
ctx := ctx
ctx.title = site.title
- ctx.content = home.body_html
+ ctx.content = home.content
ctx.pages = list_pages
ctx.og = og_for_page(site.og, home)
@@ -320,7 +320,7 @@ render_section :: proc(
ctx := ctx
if has_index {
- ctx.content = section_index.body_html
+ ctx.content = section_index.content
ctx.page_title = section_index.title
ctx.title = fmt.tprintf("%s | %s", section_index.title, site.title)
ctx.og = og_for_page(site.og, section_index)