diff options
| author | ivar <i@oiee.no> | 2026-04-03 14:46:05 +0200 |
|---|---|---|
| committer | ivar <i@oiee.no> | 2026-04-03 14:46:05 +0200 |
| commit | a46309ac64261814d931f538fad373ea8a4f0e95 (patch) | |
| tree | 6aeb1333071e433fc9e3bc7779b8b41d9e270544 /internal/admin/templates/base.html | |
| parent | a21fa502891a6d2f0600485b1b76762ecc178fd0 (diff) | |
| download | nebbet.no-a46309ac64261814d931f538fad373ea8a4f0e95.tar.xz nebbet.no-a46309ac64261814d931f538fad373ea8a4f0e95.zip | |
feat: embed admin templates into binary with //go:embed
Move admin templates from templates/admin/*.html to internal/admin/templates/*.html
and embed them using //go:embed directive. This removes the runtime dependency on
having template files on disk, allowing the templates to be compiled into the binary.
Changes:
- Add embed import and //go:embed directive for templates
- Change ParseGlob() to ParseFS() to load from embedded filesystem
- Copy templates to internal/admin/templates/ for embedding
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Diffstat (limited to 'internal/admin/templates/base.html')
| -rw-r--r-- | internal/admin/templates/base.html | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/admin/templates/base.html b/internal/admin/templates/base.html new file mode 100644 index 0000000..f88bba6 --- /dev/null +++ b/internal/admin/templates/base.html @@ -0,0 +1,34 @@ +{{define "base"}} +<!DOCTYPE html> +<html lang="en"> + +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Admin — {{.Title}}</title> + <link rel="stylesheet" href="/styles/admin.css"> + <link rel="stylesheet" href="/lib/milkdown-crepe/style.css"> + <script type="importmap"> + { + "imports": { + "@milkdown/crepe": "/lib/node_modules/@milkdown/crepe" + } + } + </script> +</head> + +<body> + <nav> + <span class="brand">Admin</span> + <a href="/admin/">Posts</a> + <a href="/admin/new">New Post</a> + </nav> + <main> + {{if eq .ContentTemplate "list-content"}}{{template "list-content" .}}{{end}} + {{if eq .ContentTemplate "form-content"}}{{template "form-content" .}}{{end}} + {{if eq .ContentTemplate "error-content"}}{{template "error-content" .}}{{end}} + </main> +</body> + +</html> +{{end}}
\ No newline at end of file |
