blog-edit.html
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
{{partial "head"}}
<title>Edit Post - {{site_name}}</title>
</head>
<body class="min-h-screen bg-base-200 flex flex-col">
{{partial "header"}}
<main class="container mx-auto p-8 flex-1">
{{with $post := document (.query.Get "id")}}
<div class="max-w-3xl mx-auto">
<div class="mb-8">
<a href="/blog" class="btn btn-ghost btn-sm gap-1">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
</svg>
Back to Blog
</a>
</div>
<h1 class="text-3xl font-bold mb-8">Edit Post</h1>
<form hx-put="/admin/collections/blog_posts/documents/{{$post.ID}}"
hx-swap="none"
hx-headers='{"X-Redirect-URL": "/blog-view?id={{$post.ID}}"}'
class="space-y-6">
<div class="form-control">
<label class="label">
<span class="label-text font-medium">Title</span>
</label>
<input type="text" name="title" value="{{$post.GetString "title"}}"
class="input input-bordered w-full" required />
</div>
<div class="form-control">
<label class="label">
<span class="label-text font-medium">Slug</span>
</label>
<input type="text" name="slug" value="{{$post.GetString "slug"}}"
class="input input-bordered w-full" required />
<label class="label">
<span class="label-text-alt text-base-content/50">URL-friendly identifier (e.g., my-first-post)</span>
</label>
</div>
<div class="form-control">
<label class="label">
<span class="label-text font-medium">Excerpt</span>
</label>
<textarea name="excerpt" rows="2"
class="textarea textarea-bordered w-full">{{$post.GetString "excerpt"}}</textarea>
<label class="label">
<span class="label-text-alt text-base-content/50">Brief summary shown in blog listing</span>
</label>
</div>
<div class="form-control">
<label class="label">
<span class="label-text font-medium">Content</span>
</label>
<textarea name="content" rows="12"
class="textarea textarea-bordered w-full font-mono">{{$post.GetString "content"}}</textarea>
</div>
<div class="form-control">
<label class="label">
<span class="label-text font-medium">Author</span>
</label>
<input type="text" name="author" value="{{$post.GetString "author"}}"
class="input input-bordered w-full" />
</div>
<div class="form-control">
<label class="label cursor-pointer justify-start gap-3">
<input type="checkbox" name="featured" value="true"
{{if $post.GetBool "featured"}}checked{{end}}
class="checkbox checkbox-primary" />
<span class="label-text font-medium">Featured post</span>
</label>
</div>
<div class="flex justify-between items-center pt-4 border-t border-base-300">
<button type="button"
hx-delete="/admin/collections/blog_posts/documents/{{$post.ID}}"
hx-confirm="Are you sure you want to delete this post? This cannot be undone."
hx-headers='{"X-Redirect-URL": "/blog"}'
class="btn btn-ghost text-error">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
Delete
</button>
<div class="flex gap-3">
<a href="/blog-view?id={{$post.ID}}" class="btn btn-ghost">Cancel</a>
<button type="submit" class="btn btn-primary">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
Save Changes
</button>
</div>
</div>
</form>
</div>
{{else}}
<div class="flex flex-col items-center justify-center py-16 text-center">
<div class="text-6xl mb-4 opacity-20">
<svg xmlns="http://www.w3.org/2000/svg" class="h-24 w-24 mx-auto" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</div>
<h3 class="text-xl font-semibold mb-2">Post Not Found</h3>
<p class="text-base-content/60 mb-6">The post you're trying to edit doesn't exist.</p>
<a href="/blog" class="btn btn-primary">Back to Blog</a>
</div>
{{end}}
</main>
{{partial "footer"}}
</body>
</html>