Validate service and industry content before any page is prerendered #230
Labels
No Label
P0
P1
P2
P3
accessibility
backend
bug
content
data-integrity
enhancement
frontend
infra
integration
owner
owner-input
performance
phase-7
phase-8
release-blocker
security
seo
ui
ux
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: null/Queue-North-Website#230
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
What is true now. Nothing checks the content layer. A misspelt block type, a missing field or a link to a route that does not exist is found by a visitor. The fallback layout maps
benefitsandidealForwith no guard, so a missing list crashes the prerender with an unhelpful TypeError.scripts/prerender.jskeeps its own route list, so a route added only tosrc/routes.jsxis never prerendered, and the server answers it with a 404.What to do.
scripts/lib/routes.js: the pure route list, used by prerender. The build fails if a router path is missing from it.scripts/lib/content.js(validateContent), run inside prerender before any page renders, so every pre-commit build and every image build refuses bad content; plusscripts/validate-content.jsas a runner for proofs.^[a-z][a-z0-9]*(-[a-z0-9]+)*$, are unique, and do not collide withcontact-form,mobile-nav-contentorsupport-portalp,list, orfaqwith every h3 followed by a psrcexists underpublic/, with alt, width and height**, backticks or](, and no sheet directionsTraps. Content modules are leaf modules: they cannot import
services.js(circular), andimport.meta.globfails in Node, where prerender imports the data. Nesting under onepagekey stops content overridingidorname.Verify:
node scripts/validate-content.jsexits 0 on the real content, and each proof mutation (a deleted benefits list, a restored em dash, a sheet direction,type: 'pp', an answer moved below its list, a bad id, a link to/services/contact-centre,#no-such-section, a missing image file) failsnpm run buildwith exactly one finding.Done in
0d575f2. scripts/lib/content.js validates the content layer and prerender.js runs it before rendering any page, so the pre-commit hook, npm run verify and the Docker image build all enforce it; scripts/validate-content.js is the standalone runner. scripts/lib/routes.js is now the single route list, and entry-server.jsx exports the router table so the build fails on drift between them. Proven by 17 mutations, each producing exactly one finding: unknown block type, FAQ answer removed, answer moved below its list, duplicate id, digit-leading id, /services/contact-centre, #no-such-section, missing image file, image without dimensions, image without alt, em dash, a website-manager direction, markdown bold, U+FFFD, HTML tag, missing hero h1, empty section; both generated content modules pass unmutated. Against a real build: an em dash in industries.js failed npm run build naming the field, and a /pricing route in src/routes.jsx failed it naming the route. Harness: scratchpad/prove-content.mjs.