diff --git a/TODOS.md b/TODOS.md new file mode 100644 index 0000000..ea75b9b --- /dev/null +++ b/TODOS.md @@ -0,0 +1,5 @@ +- [ ] add content-hash fingerprinting for tailwind cache busting. +- [ ] create template language + - Look at the source for 3 template languages that support mustache syntax, + and see how they implement the tempaltes, then pick the best one. One of them + should be Hugo / go. diff --git a/render.odin b/render.odin index 002cade..ae90900 100644 --- a/render.odin +++ b/render.odin @@ -13,27 +13,16 @@ MONTHS: [12]string = { "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", } -CSS :: ` -body { background: #020617; color: #e2e8f0; font-family: system-ui, sans-serif; max-width: 720px; margin: 0 auto; padding: 2rem; line-height: 1.6; } -a { color: #7dd3fc; } -h1, h2, h3 { color: #f1f5f9; line-height: 1.3; } -nav { display: flex; gap: 1rem; margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid #1e293b; } -pre { background: #1e293b; padding: 1rem; border-radius: 0.5rem; overflow-x: auto; } -code { font-family: monospace; font-size: 0.9em; } -p code { background: #1e293b; padding: 0.1em 0.3em; border-radius: 0.25em; } -blockquote { border-left: 4px solid #475569; margin: 0; padding: 0.5rem 0 0.5rem 1rem; color: #94a3b8; } -img { max-width: 100%; } -hr { border: none; border-top: 1px solid #1e293b; } -table { border-collapse: collapse; width: 100%; } -th, td { border: 1px solid #334155; padding: 0.5rem; } -` - -NAV :: ` - +HEADER :: ` +
+ +
` render_site :: proc(pages: []Page, output_dir: string) { @@ -56,7 +45,7 @@ render_site :: proc(pages: []Page, output_dir: string) { render_page_html :: proc(page: Page) -> string { body := fmt.aprintf( `
-
+

%s

%s %s
@@ -82,9 +71,10 @@ render_home_html :: proc(pages: []Page) -> string { body := fmt.aprintf( `
-
-

%s

-

%s

+
+ +

%s

+

%s

    %s @@ -103,7 +93,8 @@ render_posts_html :: proc(pages: []Page) -> string { parts: [dynamic]string defer delete(parts) - append(&parts, "
    \n

    Posts

    \n") + append(&parts, "
    \n") + append(&parts, `

    Posts

    ` + "\n") current_year := "" open := false @@ -114,17 +105,20 @@ render_posts_html :: proc(pages: []Page) -> string { year := get_year(page.date) if year != current_year { if open { - append(&parts, "
\n") + append(&parts, " \n \n") } open = true current_year = year - append(&parts, fmt.aprintf("

%s

\n
\n
    \n", year)) + append( + &parts, + fmt.aprintf("
    \n

    %s

    \n
    \n
      \n", year), + ) } append(&parts, render_post_item(page)) append(&parts, "\n") } if open { - append(&parts, "
    \n") + append(&parts, "
\n \n") } append(&parts, "
\n") @@ -141,16 +135,20 @@ render_chrome :: proc(page_title: string, body: string) -> string { %s - + -%s%s +%s%s `, page_title, - CSS, - NAV, + HEADER, body, ) } @@ -158,18 +156,22 @@ render_chrome :: proc(page_title: string, body: string) -> string { render_post_item :: proc(page: Page) -> string { date_html := "" if page.date != "" { - date_html = fmt.aprintf(" ", format_date(page.date)) + date_html = fmt.aprintf( + "", + page.date, + format_date(page.date), + ) } star := "" if page.is_starred { - star = " \xe2\x98\x85" + star = `` } return fmt.aprintf( - `
  • %s%s%s
  • `, + `
  • %s%s%s
  • `, page.permalink, page.title, - date_html, star, + date_html, ) }