refactor: define Hugo's effective-page-type rule once in internal/pagepath #122
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!122
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "afk/115"
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?
Closes #115
Hugo's effective-page-type rule ("explicit front-matter
typewhen non-empty, else the page's top-level section name") existed three times:pageops.effectiveTypeOf/impliedType, a byte-for-byte local copy inpagetree(fossilized because pageops imports pagetree, not the reverse), and the web client'seffectiveNodeType/impliedPageType.What changed
internal/pagepathowning the pure rule:ImpliedType(pagePath)andEffectiveType(pagePath, explicitType). The package doc records the full semantics, including the leaf-bundle case (posts/foo/index.md→posts,foo/index.mdat root →"") and the content-root case (_index.md→"").internal/pageopsdeletes its privateimpliedType;effectiveTypeOfis now a thin front-matter-reading wrapper that extracts the explicit type (empty on any read/decode/cast failure — permissive as before) and delegates. The exportedpageops.EffectiveType(root, page)signature and behavior are unchanged, so the HTTP layer needed no edits.internal/pagetreedeletes its localeffectiveType/impliedTypecopies and their "mirrors … byte for byte" comments; the one call site delegates, keeping the governs-the-node's-children insight as a call-site comment.internal/pagepath/testdata/effective_type_cases.json(12 cases), consumed by BOTH the Go test (pagepath_test.go) and the web unit test (pagemanage.test.ts). Verified both directions: mutating an expected value in the fixture fails the Go suite and the web suite on exactly that case; restored, both are green.No behavior change anywhere — pure consolidation.
internal/pagetype's no-resolution boundary andscaffold/site/AGENTS.mdare untouched (out of scope per the issue).Verification
go vet ./...clean;gofmtclean on all touched filesgo test ./...(with hugo on PATH so the skip-prone suites run): all pass, including the newinternal/pagepathconformance testvitest run947/947 pass (12 new conformance tests);tsc --noEmitclean🤖 Generated with Claude Code
Landing audit — PASS, merged
Verification signal relied on: Forgejo Actions
ci / build-and-test (pull_request)— success in 6m2s. Not re-run locally; the repo's own CI already exercised this diff.Checked:
refactor:).afk/115carries a workingCloses #115.main(no conflict, no resolution commit).Review notes:
internal/pagepathis genuinely stdlib-only (path,strings), satisfying the leaf-package constraint.pageops.effectiveTypeOfrewrite is behavior-preserving: the old code returnedsonly whencastErr == nil && s != "", else fell through toimpliedType; the new code assignsexplicit = son a clean cast and letspagepath.EffectiveTypeapply the same!= ""test. Identical on every path, including the empty-string-type case.path/stringsremain used inpagetree/build.goandpageops/paths.go, so no dangling imports.internal/pagepath/testdata/effective_type_cases.json.internal/pagetype's boundary andscaffold/site/AGENTS.mduntouched.Minor nit, non-blocking (not fixed):
web/src/test/pagemanage.test.tsuses@ts-expect-erroron thenode:fsimport. If@types/nodeis ever added, the directive itself becomes an error ("unused") and breakstsc;@ts-ignorewould be inert. Test-file-only, with an explanatory comment.