{ post.Title }
++ @postDate(post.Date) +
+From 1d247493e05cdc659e46cd3d8a01d5da1e893867 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Tue, 18 Jun 2024 16:46:22 +0200 Subject: switch to templ for rendering HTML templates --- .gitignore | 3 + go.mod | 1 + go.sum | 2 + internal/builder/404.templ | 13 ++ internal/builder/builder.go | 62 ++++------ internal/builder/homepage.templ | 54 ++++++++ internal/builder/list.templ | 48 ++++++++ internal/builder/page.templ | 84 +++++++++++++ internal/builder/post.templ | 50 ++++++++ internal/builder/tags.templ | 23 ++++ internal/builder/template.go | 265 ++-------------------------------------- modd.conf | 4 +- nix/gomod2nix.toml | 3 + shell.nix | 2 + templates/404.html | 37 ------ templates/count.html | 8 -- templates/dev.html | 8 -- templates/homepage.html | 63 ---------- templates/list.html | 52 -------- templates/post.html | 78 ------------ templates/style.css | 1 + templates/tags.html | 42 ------- 22 files changed, 324 insertions(+), 579 deletions(-) create mode 100644 internal/builder/404.templ create mode 100644 internal/builder/homepage.templ create mode 100644 internal/builder/list.templ create mode 100644 internal/builder/page.templ create mode 100644 internal/builder/post.templ create mode 100644 internal/builder/tags.templ delete mode 100644 templates/404.html delete mode 100644 templates/count.html delete mode 100644 templates/dev.html delete mode 100644 templates/homepage.html delete mode 100644 templates/list.html delete mode 100644 templates/post.html delete mode 100644 templates/tags.html diff --git a/.gitignore b/.gitignore index 88424a9..e40b491 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ go.work /result .vercel /.netlify/ + +*_templ.go +*_templ.txt diff --git a/go.mod b/go.mod index 5495a00..5660e67 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/BurntSushi/toml v1.3.2 github.com/PuerkitoBio/goquery v1.9.2 github.com/a-h/htmlformat v0.0.0-20231108124658-5bd994fe268e + github.com/a-h/templ v0.2.707 github.com/adrg/frontmatter v0.2.0 github.com/antchfx/xmlquery v1.4.0 github.com/antchfx/xpath v1.3.0 diff --git a/go.sum b/go.sum index c65524b..398c65f 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,8 @@ github.com/Code-Hex/dd v1.1.0 h1:VEtTThnS9l7WhpKUIpdcWaf0B8Vp0LeeSEsxA1DZseI= github.com/Code-Hex/dd v1.1.0/go.mod h1:VaMyo/YjTJ3d4qm/bgtrUkT2w+aYwJ07Y7eCWyrJr1w= github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE= github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk= +github.com/a-h/templ v0.2.707 h1:T1Gkd2ugbRglZ9rYw/VBchWOSZVKmetDbBkm4YubM7U= +github.com/a-h/templ v0.2.707/go.mod h1:5cqsugkq9IerRNucNsI4DEamdHPsoGMQy99DzydLhM8= github.com/adrg/frontmatter v0.2.0 h1:/DgnNe82o03riBd1S+ZDjd43wAmC6W35q67NHeLkPd4= github.com/adrg/frontmatter v0.2.0/go.mod h1:93rQCj3z3ZlwyxxpQioRKC1wDLto4aXHrbqIsnH9wmE= github.com/alanpearce/htmlformat v0.0.0-20240425000139-1244374b2562 h1:7LpBXZnmFk8+RwdFnAYB7rKZhBQrQ4poPLEhpwwbmSc= diff --git a/internal/builder/404.templ b/internal/builder/404.templ new file mode 100644 index 0000000..049e67d --- /dev/null +++ b/internal/builder/404.templ @@ -0,0 +1,13 @@ +package builder + +import "website/internal/config" + +templ notFound(config config.Config, path string) { + @page(config, PageSettings{ + Title: "Not Found", + Path: path, + }) { +
+ @postDate(post.Date) +
+- -
-/bin/test
-
-
-
-foo=bar
-
-
-
- One | -Two | -Three | -
---|---|---|
1 | -2 | -3 | -