feat: edit one element end-to-end — sidecar schemas, generated form, canonical save, live preview #20
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/deckle!20
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "afk/3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
First true editing tracer bullet: a param edit travels from a schema-generated form through validation and the #2 round-trip engine onto disk, and the Hugo preview picks it up via LiveReload.
What's in here
internal/element— sidecar schema package: discoverseditor/elements/*.yaml|yml(one file per shortcode), strict-validates them (unknown types, malformed files, bad defaults → actionable per-file errors while valid sidecars keep loading), and validates/coerces edited param values into content-engine types. Nine v1 field types: text, textarea, link, image, select, checkbox, number, color, date. Importable without the server;goccy/go-yamlpromoted to a direct dependency.internal/server—GET /api/elements(schemas + load errors, loaded fresh per request),GET /api/page(parsed tree; shares the/api/debug/treeimplementation),POST /api/page/save(locate shortcode by child-index path with 409 on drift, server-authoritative validation returning 422 field errors, non-schema params preserved, atomic same-dir temp+rename write of only that page's file in canonical form).server.Newnow takes the site dir.web/— Elements pane with a crude page-path input (real navigation is #4), shortcode list derived from the parsed tree, sidecar load errors listed verbatim; Edit pane renders a form generated purely from the schema (labels, defaults, required markers, select options — zero element-specific branches), client-side validation inline, server 422 errors mapped per field, save button + saved indicator, post-save tree swap keeping the selection.testdata/site—hero(inline) andnotice(block, markdown body) element types covering all nine field types, with visible templates and a canonical homepage using both.Acceptance criteria → evidence
internal/elementload tests (17 error cases),/api/elementsbroken-sidecar test,schema-errorsUI section + testTestElementsHappyPath(sorted, arrays never null)TestSavePageHappyPath(byte-exact expected file, site-dir snapshot diff, unknown params survive, empty optional removed, integral numbers stay ints) — also verified against a live harnessChange detected, rebuilding site, preview served the new value, LiveReload script present, no Hugo restart{errors:[{param,msg}]}+ client mirror, tested on both sidesFull suite green:
go vet ./...,go test ./...,npx tsc --noEmit,npm test(15),npm run build, plus a live end-to-end save exercised over HTTP.Closes #3