feat(pages): same-page #name links on landing pages #58

Merged
ngqile merged 8 commits from add-page-anchor-links into main 2026-12-03 01:48:08 +00:00
Owner

OpenSpec change add-page-anchor-links. Design: docs/superpowers/specs/2026-12-03-page-anchor-links-design.md.

What

  • Each landing-page block has an optional Link name: lowercase letters, digits and -, up to 40 characters, unique on the page, and not starting with reg-. The public page renders it as the block's id.
  • Button and rich-text links accept #name. The same rule applies in services-counter, isSafeLink, the rich-text editor and the sanitiser.
  • Custom HTML frames: the injected frame script turns clicks on #name links into a colite-frame-anchor message. The page acts only on messages from its own frame, with the name checked against the pattern, and only scrolls. The target is the frame's own id first, then a named block in <main>. The frame gets no new sandbox grants.
  • reg- is reserved because the sign-up form renders its fields with literal reg-* ids, so a block named reg-email would have duplicated an input id. Other ids on the public page come from useId.
  • Labels in English and Chinese: sql/01-anchor-labels.sql (DML only, no DDL) and sql/99-rollback.sql.

Verification

  • services-counter: 360 tests green.
  • Portal: vitest 1892 passed / 1 skipped (exit 0), tsc clean, lint 0 errors (4 old warnings).
  • Live Playwright check on a local portal from this branch, using two disposable INS pages that were deleted afterwards:
    • a bad link name, a reserved name (reg-email) and a duplicate name are each refused at their field;
    • an in-frame #signup link scrolls to the form (1280 and 360 px);
    • an in-frame #top link scrolls back to the start of the frame;
    • a Hero button linking to #signup jumps to the form (360 px);
    • a rich-text #signup link added through the editor's link prompt jumps to the form (360 px);
    • no sideways scroll at 360 px.
  • Not run live: link-name ids in the staff preview, and the Hero button at 1280 px.

Notes

  • One existing test (PageEditor.test.tsx) changed only to match the reworded PagesBadLink text.
  • On the INS page after deploy, staff name the form block signup and change #consult to #signup in its HTML (see docs/deployment.md §12).

🤖 Generated with Claude Code

https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs

OpenSpec change `add-page-anchor-links`. Design: `docs/superpowers/specs/2026-12-03-page-anchor-links-design.md`. ## What - Each landing-page block has an optional **Link name**: lowercase letters, digits and `-`, up to 40 characters, unique on the page, and not starting with `reg-`. The public page renders it as the block's id. - Button and rich-text links accept `#name`. The same rule applies in services-counter, `isSafeLink`, the rich-text editor and the sanitiser. - Custom HTML frames: the injected frame script turns clicks on `#name` links into a `colite-frame-anchor` message. The page acts only on messages from its own frame, with the name checked against the pattern, and only scrolls. The target is the frame's own `id` first, then a named block in `<main>`. The frame gets no new sandbox grants. - `reg-` is reserved because the sign-up form renders its fields with literal `reg-*` ids, so a block named `reg-email` would have duplicated an input id. Other ids on the public page come from `useId`. - Labels in English and Chinese: `sql/01-anchor-labels.sql` (DML only, no DDL) and `sql/99-rollback.sql`. ## Verification - services-counter: 360 tests green. - Portal: vitest 1892 passed / 1 skipped (exit 0), `tsc` clean, lint 0 errors (4 old warnings). - Live Playwright check on a local portal from this branch, using two disposable INS pages that were deleted afterwards: - a bad link name, a reserved name (`reg-email`) and a duplicate name are each refused at their field; - an in-frame `#signup` link scrolls to the form (1280 and 360 px); - an in-frame `#top` link scrolls back to the start of the frame; - a Hero button linking to `#signup` jumps to the form (360 px); - a rich-text `#signup` link added through the editor's link prompt jumps to the form (360 px); - no sideways scroll at 360 px. - Not run live: link-name ids in the staff preview, and the Hero button at 1280 px. ## Notes - One existing test (`PageEditor.test.tsx`) changed only to match the reworded `PagesBadLink` text. - On the INS page after deploy, staff name the form block `signup` and change `#consult` to `#signup` in its HTML (see `docs/deployment.md` §12). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
ngqile added 7 commits 2026-12-03 01:35:28 +00:00
ngqile added 1 commit 2026-12-03 01:47:58 +00:00
A block named reg-email would have duplicated the form's input id, so its
label and #reg-email links would bind to the wrong element.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
ngqile merged commit 7229437ced into main 2026-12-03 01:48:08 +00:00
ngqile deleted branch add-page-anchor-links 2026-12-03 01:48:09 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ngqile/co-lite#58