13 Commits
Author SHA1 Message Date
poli0981andClaude Fable 5.2 24d7c1b117 test(a11y): wider coverage, status checks, and claims that match it
Every sitemap page is checked for sideways scrolling at 320px; the light-theme and phone scans cover a page of every template; a page that does not answer the expected status fails instead of being scanned as an error page; the search focus trap is exercised with results listed; the legal notice is checked at tablet and small-laptop sizes; the story reader is walked backwards with Shift+Tab; each half of a legal page must declare its language. ACCESSIBILITY.md says what the palette test and the suite actually cover, and that the live widgets are not in the test build. CI prints the preview log when the job fails.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 7511f0c45e fix(a11y): findings from an independent review of the branch
Regressions from this branch: overflow-wrap anywhere broke words inside the AI-usage table (break-word now, with minmax(0, 1fr) grid columns so the legal layout can still shrink); the legal notice kept covering footer controls between 768 and about 1100px (the body makes room for it at every width); the home link was a 32x12px mark once the wordmark was hidden (it keeps a 40px box); the sitemap filter dropped any path containing an admin segment (anchored to the host root); prefers-contrast did not reach the sepia reader theme.

Older bugs the new statement made claims about: Tab could leave the search dialog once results were listed, because the trap counted the tabindex=-1 options; and the half of a legal page that is not in the page's language had no lang (each half is wrapped at build time, src/lib/legal-lang.ts).

Found by the wider reflow sweep: the album photo grid used 1fr columns, which grew past a 320px screen.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 9f0a704280 docs: note the admin routes excluded from the sitemap
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 28400cc2bc fix(ui): keep the space around the breadcrumb slash
Turning the project, gallery and tag breadcrumbs into nav landmarks split them into elements, and the build strips the whitespace between elements: they rendered as one run-together string. They are flex rows with a gap now, like the post breadcrumb.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 b6a5282a41 fix(a11y): measure the legal notice from its own height, not its offset
The height published for the page's scroll padding came from offsetTop, which is not guaranteed to be viewport-relative for a fixed element once the page is scrolled. It is now the sheet's height plus its gap to the bottom edge, and the suite checks the published value against what the sheet covers after the page has scrolled, and that it is removed with the sheet.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 a6aef58b46 docs: absolute link to ACCESSIBILITY.md in the pull request template
The template's text becomes a pull request body, where a relative link resolves against the pull request's URL, not the repository tree.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 21178aa35f docs: accessibility across README, changelog 2.2.0 and the design docs
README gains an Accessibility section and the test:a11y command. CHANGELOG 2.2.0. Design docs: decision D20, the a11y target in the PRD, the checklist in 03 section 8, the legal route list and legal notice in 05, the accessibility@ alias in 07, the CI gate in 08, the roadmap entry and the maintenance tasks in 17.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 0fb60fe867 test(a11y): axe-core, keyboard, reflow and forced-colours suite in the build check
npm run test:a11y drives the installed Chrome through Playwright against npm run preview: axe-core (WCAG 2.2 A and AA plus best practices) over every page in the build's sitemap, one page per template again in the light theme and at phone width, and the menu, search, photo viewer, report dialog, reading settings and legal notice while open; then the keyboard contract, no sideways scrolling at 320, 360 and 390px, and the forced-colours rules. It runs inside the required build job after the smoke test. New dev dependencies playwright 1.65.0 and @axe-core/playwright 4.14.0, both past the three-day cooldown and without install scripts. sonar.projectVersion catches up to 2.2.0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 6ce2b7077f feat(a11y): forced colours, cues beyond colour, focus and reflow fixes
Forced colours (Windows High Contrast): the search field and its active result keep an outline, the scrollbar switch shows its knob and state, the chosen reading option is filled. prefers-contrast: more strengthens hairlines and drops the grain.

Not by colour alone: the current page is underlined in the header and the legal sidebar and gets a bar on its tab; the chosen reading option is bold and double-ruled; links inside the Q&A contact list are underlined.

Focus: scroll padding now clears the mobile tab bar, the story reader bar and the legal notice, which rests on top of the tab bar instead of covering it and publishes its height. Esc in the reading panel returns focus to the Aa button; pressing play keeps focus on the player; the report form ties its error to the field.

Reflow: the header needed 378px (vi) or 400px (en), so pages scrolled sideways at 360px and English pages did at 390px. The language switch shows its code below those widths and the wordmark goes below 352px; prose breaks long URLs.

Names and structure: unique names for the navs that shared one with the footer, play buttons carry their video title, the search close button is named Esc - Close, card headings take a level so lists no longer skip h2, breadcrumbs and the legal notice are landmarks, the photo viewer announces the caption on change. Footer social icons are 44px targets.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 84ce2b8876 fix(seo): keep the admin routes out of the sitemap
The sitemap listed seven /admin/ URLs. They are prerendered shells that only exist on admin.poli0981.dev; on this host they answer 301 or 403. Found while driving the accessibility suite from the sitemap.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 004cf466ce feat(a11y): accessibility statement, issue and PR templates
A seventh legal page, /legal/accessibility (content repo c9e9827), linked from the footer, the menu, the legal sidebar and the legal notice. ACCESSIBILITY.md at the root is the repository's copy with the notes for contributors, which also ticks the Accessibility entry of GitHub's community standards. New issue template (label accessibility) and a pull request template carrying the checklist. The content bump also brings alt text for the four FrameLedger screenshots.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 46cede84e3 chore(deps): Tailwind CSS 4.3.5 (#125)
tailwindcss and @tailwindcss/vite 4.3.4 -> 4.3.5, with their transitive patches (npm update --save --before=2026-11-06T23:43Z, the same three-day cooldown Dependabot applies). Astro 7.4.8, jose 6.2.17, marked 18.2.0, typescript-eslint 8.72.2, wrangler 4.159.0, eslint-plugin-svelte 3.24.1 and knip 6.44.2 are younger than three days and wait for the next Dependabot run.

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 07:12:43 +07:00
dependabot[bot] 5eb87b45d5 chore(deps): Bump SonarSource/sonarqube-scan-action from 8.4.0 to 8.4.1 (#124)
Bumps [SonarSource/sonarqube-scan-action](https://github.com/sonarsource/sonarqube-scan-action) from 8.4.0 to 8.4.1.
- [Release notes](https://github.com/sonarsource/sonarqube-scan-action/releases)
- [Commits](https://github.com/sonarsource/sonarqube-scan-action/compare/4d1dc0c91ee400dcf8a6dddf2f705ac36542e304...e805d875275f728fac1885b413934be6d7c63f65)

---
updated-dependencies:
- dependency-name: SonarSource/sonarqube-scan-action
  dependency-version: 8.4.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-09 20:53:14 +07:00
61 changed files with 1692 additions and 183 deletions

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
name: Rào cản trợ năng / Accessibility barrier
description: Điều gì đó trên poli0981.dev khó hoặc không dùng được / Something on poli0981.dev is hard or impossible to use
title: "[a11y] "
labels: ["accessibility"]
body:
- type: markdown
attributes:
value: |
Cảm ơn bạn đã báo. Bạn không cần tự tìm nguyên nhân, và không cần nói gì về tình trạng khuyết tật của mình.
Thanks for reporting. You do not have to diagnose anything, and you never need to tell me about a disability.
Không muốn đăng công khai? Gửi email tới accessibility@poli0981.dev hoặc dùng nút "Báo lỗi" ở cuối mọi trang (không cần tài khoản).
Prefer not to post in public? Email accessibility@poli0981.dev, or use "Report a bug" at the bottom of every page (no account needed).
- type: textarea
id: goal
attributes:
label: Bạn đang định làm gì? / What were you trying to do?
description: Ví dụ "mở menu bằng bàn phím" / For example "open the menu with the keyboard"
validations:
required: true
- type: textarea
id: barrier
attributes:
label: Điều gì đã xảy ra? / What happened instead?
description: Các bước tái hiện nếu có / Steps to reproduce, if you have them
validations:
required: true
- type: input
id: route
attributes:
label: Trang / Page
placeholder: "https://poli0981.dev/…"
- type: textarea
id: environment
attributes:
label: Môi trường / Environment
description: Hệ điều hành, trình duyệt, công nghệ hỗ trợ và phiên bản / Operating system, browser, assistive technology and versions
placeholder: "Windows 11 · Edge 142 · Narrator"
- type: dropdown
id: severity
attributes:
label: Mức độ / Severity
description: Để mình biết nên xử lý cái nào trước / So I know what to handle first
options:
- "Chặn hẳn — không làm được việc chính / Critical — blocks a core task"
- "Nghiêm trọng — rất khó, nhưng có cách khác / Serious — major difficulty, a workaround exists"
- "Vừa — gây khó chịu hoặc không nhất quán / Moderate — annoying or inconsistent"
- "Nhẹ — ảnh hưởng ít / Minor — little impact"
validations:
required: true
+22
View File
@@ -0,0 +1,22 @@
## What and why
<!-- One or two sentences. Link the issue if there is one. -->
## Checks
- [ ] `npm run format:check`, `npm run lint`, `npm run check`, `npm run typecheck`, `npm test`
- [ ] `CHANGELOG.md` updated under `[Unreleased]` when visitors or operators would notice the change
## Accessibility (only if the interface changed)
See [`ACCESSIBILITY.md`](https://github.com/poli0981/poli0981-dev/blob/main/ACCESSIBILITY.md).
`npm run test:a11y` covers what a machine can check; the rest is by hand.
- [ ] Works with the keyboard alone, start to finish; focus is visible and never lands under a fixed bar
- [ ] Anything that opens (menu, dialog, panel) closes with Esc and hands focus back to what opened it
- [ ] Icon-only controls have a name that starts with their visible text, taken from `src/i18n`
- [ ] State and "you are here" are not shown by colour alone; new colours go through `tests/palette.test.ts`
- [ ] Headings do not skip a level; images have an `alt` (empty only when decorative)
- [ ] New animation has a still branch under `prefers-reduced-motion`
- [ ] Looked at 320 px wide, at 200% zoom, in dark and light, in Vietnamese and English
- [ ] Listened to once with a screen reader
+24 -1
View File
@@ -117,6 +117,29 @@ jobs:
- name: Smoke test built worker
run: npm run smoke
# Accessibility gate (ACCESSIBILITY.md). The same build is served by `astro preview`
# (workerd, real bindings, no bot gate without its secrets) and driven with the
# runner's own Chrome — Playwright downloads no browser. axe-core scans every page in
# the sitemap and the dialogs while open; the keyboard, reflow and forced-colours
# checks follow. Runs inside this job because `build` is the required status check.
- name: Start preview server
run: |
npm run preview > "$RUNNER_TEMP/preview.log" 2>&1 &
for i in $(seq 1 60); do
if curl -sf -o /dev/null http://localhost:4321/; then
echo "preview up after ${i}s"; exit 0
fi
sleep 1
done
echo "preview server never came up"; cat "$RUNNER_TEMP/preview.log"; exit 1
- name: Accessibility tests (axe + keyboard)
run: npm run test:a11y
- name: Preview server log (on failure)
if: failure()
run: tail -n 100 "$RUNNER_TEMP/preview.log" || true
- name: Upload coverage
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
@@ -160,7 +183,7 @@ jobs:
# quality gate and fails with it, so a red gate is visible on the PR; on main it only
# reports (the gate there is a trend, not a merge decision).
- name: SonarCloud scan
uses: SonarSource/sonarqube-scan-action@4d1dc0c91ee400dcf8a6dddf2f705ac36542e304 # v8.4.0
uses: SonarSource/sonarqube-scan-action@e805d875275f728fac1885b413934be6d7c63f65 # v8.4.1
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
+154
View File
@@ -0,0 +1,154 @@
# Accessibility
How accessibility is handled on [poli0981.dev](https://poli0981.dev): what the site aims for, what is
in place, how it is tested, what is known not to work, and how to report a barrier.
The statement written for visitors, in English and Vietnamese, is on the site at
[`/legal/accessibility`](https://poli0981.dev/legal/accessibility/) (and
[`/en/legal/accessibility`](https://poli0981.dev/en/legal/accessibility/)). This file is the
repository's copy, with the notes for people who work on the code — if the two ever disagree about
what a visitor can expect, the site wins.
> Tiếng Việt: tuyên bố trợ năng dành cho khách truy cập nằm ở
> [`/legal/accessibility`](https://poli0981.dev/legal/accessibility/). Gặp rào cản? Gửi email tới
> **accessibility@poli0981.dev** hoặc dùng nút "Báo lỗi" ở cuối mọi trang.
## Reporting a barrier
Email **accessibility@poli0981.dev**, or use **Report a bug** at the bottom of every page — it needs
no account and lands in a private tracker. If you use GitHub, you can open an issue with the
[Accessibility template](https://github.com/poli0981/poli0981-dev/issues/new?template=accessibility.yml).
It helps to say which page, what you were trying to do, what happened instead, and which browser and
assistive technology you use. You do not have to diagnose anything, and you never need to tell me
about a disability.
Expect a reply within 7 days. Reports are handled in this order:
- **Critical** — blocks a core task (reading a page, moving around the site, reporting a problem)
- **Serious** — major difficulty, but there is another way to do it
- **Moderate** — annoying or inconsistent
- **Minor** — little impact
This is a personal site maintained by one person, in their spare time, so there is no fixed date for
every fix. You will be told what is planned, and a workaround if there is one.
## Target
[WCAG 2.2](https://www.w3.org/TR/WCAG22/) Level AA, used as the guide for design and review. The site
has not been audited by a third party, and this is not a claim of conformance.
## What is in place
- **Keyboard.** Every page works with the keyboard alone. There is a skip link
(`src/components/SkipLink.astro`) and one focus ring for everything (`src/styles/global.css`). The
menu sheet, the search and the photo viewer trap focus while open, close with Esc and hand focus
back to what opened them; the report form is a native `<dialog>`. `/` opens the search. The
page's scroll padding keeps whatever takes focus clear of the sticky header, the mobile tab bar
and the legal notice.
- **Screen readers.** Each page declares its language, and text in the other language carries its
own: the language switch, and each half of a legal page, which holds both languages
(`src/lib/legal-lang.ts`). There is one `<h1>` per page and heading levels do not skip. Every `<nav>` has its own name, taken
from `src/i18n`. Icon-only controls are named, and a name starts with the text that is visible
(WCAG 2.5.3). The search is an ARIA combobox. Live regions announce search results, the photo
viewer's position and caption, and the report form's status.
- **Colour and contrast.** In both palettes, text is at least 4.5:1 on every surface it sits on,
and the line colour used where a boundary has to be seen is at least 3:1;
`tests/palette.test.ts` fails the build if one drops below. Decorative hairlines are fainter.
The current page and a chosen option are never shown by colour alone. Windows High Contrast (`forced-colors`) and
`prefers-contrast: more` are handled.
- **Motion.** One global rule collapses every animation under `prefers-reduced-motion`, and
scripted motion follows it (`src/lib/motion.ts`). Nothing loops or plays by itself; a YouTube
video loads only after its play button is pressed.
- **Zoom and reflow.** Type is fluid and in `rem`, zooming is never locked, and pages reflow down
to a 320 px viewport.
- **Touch.** The tab bar's targets are 56 px tall, the header's controls 40 px and the footer's
icons 44 px. Text links in the footer and the sidebars are about 24 px tall or less and meet
WCAG 2.5.8 through the space around them.
- **Reading.** Stories have their own settings: three text sizes and a paper, sepia or dark
background.
## Tested with
| How | What |
| ---------------- | ------------------------------------------------------------------ |
| Keyboard only | Chrome, Edge and Brave on Windows 11 |
| Windows Narrator | Edge, Chrome and Brave on Windows 11 |
| VoiceOver | Safari on iPhone |
| Automated | axe-core in Chrome, on every pull request (see "For contributors") |
Not yet tested by the maintainer: NVDA, JAWS, TalkBack, VoiceOver on macOS, and voice control. They
are expected to work; a report saying otherwise is welcome.
The site supports the current versions of Chrome, Edge, Firefox and Safari, on desktop and mobile.
## Known limitations
- **Bot check.** A first visit passes through a Cloudflare Turnstile check. It usually needs no
action, but it is a third-party component this repository cannot change. Anyone it stops can
write to the address above.
- **Videos.** Videos are YouTube embeds. Captions are whatever YouTube provides for each video;
there are no transcripts.
- **Older images.** Gallery photos must have a caption in both languages (the build fails
otherwise). A few images inside older posts may still lack a text alternative.
- **Offline mini-game.** The game on the offline page is drawn on a canvas. It can be played with
the Space key, but a screen reader cannot follow it. It is an extra, not content.
- **Search** needs JavaScript. Without it, every page is still reachable from the menu and the
footer links.
- **The admin** (`admin.poli0981.dev`) is a single-owner tool and is not covered by this document.
- **Automated checks run in Chrome only**, and no tool can judge everything: a passing run is
necessary, not sufficient. The live widgets (latest video, now playing) have no data in the
test build, so their markup is checked by hand.
## For contributors
A change to the interface is expected to keep all of this true:
- It works with the keyboard alone, start to finish; focus is visible and never lands under a fixed bar.
- Anything that opens closes with Esc and hands focus back to what opened it.
- Icon-only controls have a name that starts with their visible text, taken from `src/i18n`.
- State and "you are here" are not shown by colour alone. A new colour goes into
`src/lib/palette.ts` and `src/styles/global.css` together, where the palette test checks it.
- Headings do not skip a level; images have an `alt`, empty only when they are decorative.
- New animation has a still branch under `prefers-reduced-motion`.
- It has been looked at 320 px wide, at 200% zoom, in dark and light, in Vietnamese and English,
and listened to once with a screen reader.
What the pipeline checks:
- **`npm run test:a11y`** runs in the required `build` check, so a pull request with a violation
cannot be merged. It scans every page listed in the build's sitemap with axe-core (WCAG 2.2 A and
AA rules plus axe's best practices), a page of each template again in the light theme and at
phone width, and the menu, search, photo viewer, report dialog, reading settings and legal notice
while they are open. It then walks the keyboard contract — the skip link, focus traps, Esc and
focus return, focus not hidden under a bar in either direction — checks that no page scrolls
sideways at 320 px (and a sample at 360 and 390 px), and checks the forced-colours rules. The
tests are in `tests/a11y/`.
- **`tests/palette.test.ts`** checks the text and line colours of both palettes against AA.
- **Lighthouse** reports an accessibility score on pull requests; it is advisory.
To run the suite locally, build and serve the site, then run it from a second terminal:
```bash
npm run build
```
```bash
npm run preview
```
```bash
npm run test:a11y
```
It drives the Chrome that is already installed; set `A11Y_CHANNEL=msedge` to use Edge instead. If a
rule cannot be met, say why in the pull request rather than switching the rule off.
## Ownership and review
Maintained by Kokone ([poli0981](https://github.com/poli0981)), the site's only maintainer, who
triages reports and keeps this file and the site's statement in step. Both are reviewed with every
release that changes the interface and at least once a year
([`17_MAINTENANCE.md`](poli0981.dev-docs/17_MAINTENANCE.md)).
Last reviewed: 2026-11-10 (v2.2.0).
+56 -1
View File
@@ -7,6 +7,60 @@ and are not listed here.
## [Unreleased]
## [2.2.0] — 2026-11-10
### Added
- **Accessibility statement.** A new page, `/legal/accessibility` (Vietnamese and English), says
what the site aims for (WCAG 2.2 AA, as a guide — it has not been audited), what is in place, how
it is tested, what is known not to work and how to report a barrier: a new address,
accessibility@poli0981.dev, or the "Report a bug" button. [`ACCESSIBILITY.md`](ACCESSIBILITY.md)
is the repository's copy, with the notes for contributors; there is an accessibility issue
template and a pull request template with the checklist.
- **Accessibility gate in CI.** `npm run test:a11y` runs in the required `build` check: axe-core
over every page in the sitemap and over the menu, search, photo viewer, report dialog, reading
settings and legal notice while open, then keyboard, reflow and forced-colours tests
(`tests/a11y/`, Playwright driving the runner's Chrome). Lighthouse stays advisory.
- Windows High Contrast (`forced-colors`): the search field and its active result keep a visible
indicator, the scrollbar switch shows its knob and state, and the chosen reading option is
filled. `prefers-contrast: more` strengthens hairlines and drops the film grain.
### Changed
- The current page is marked by more than colour: an underline in the header and in the legal
sidebar, a bar along the top of the current tab on phones. The chosen reading option is bold and
double-ruled.
- Footer social icons are 44 px targets (the icons keep their size); the row is a little wider.
- On a phone the legal notice rests on top of the tab bar instead of covering it.
- Below 384 px (Vietnamese pages) or 404 px (English pages) the language switch shows `EN` / `VI`
instead of the full name, and below 352 px the header drops the "SkullMute" wordmark.
- Dependencies: Tailwind CSS 4.3.5. New dev dependencies: `playwright` 1.65 and
`@axe-core/playwright` 4.14, both older than the three-day cooldown and without install scripts.
### Fixed
- The header was wider than the screen on narrow phones — it needs 378 px in Vietnamese and 400 px
in English — so pages scrolled sideways at 360 px, and English pages did on a 390 px iPhone. Pages
now reflow down to 320 px; a long URL in a legal page no longer widens it either.
- Focus could land underneath the mobile tab bar, the legal notice or the story reader's bar. The
page's scroll padding now accounts for all three.
- Esc in the story reader's "Aa" panel dropped focus to the top of the page; it returns to the
button. Pressing play on a video keeps focus on the player.
- Tab could walk out of the search dialog once results were listed; the trap now counts only what
Tab can reach.
- A legal page holds both languages, and the half that is not in the page's language had no
`lang`, so a screen reader read it with the wrong voice. Each half now declares its own.
- Names: the three "Play video" buttons on the gaming page each carry their video's title; the
search's "Esc" button is named "Esc — Close"; the "Social" and "Legal" navs that shared a name
with the footer's (dev and gaming pages, menu sheet, legal sidebar) have their own.
- Headings no longer skip from h1 to h3 on the blog, tag, project and gallery lists. Project,
gallery and tag breadcrumbs are navigation landmarks, and the legal notice is a landmark.
- Links inside the Q&A contact list are underlined, not told apart by colour alone.
- The report form ties its "too short" message to the text box and returns focus there. The photo
viewer announces the caption when you move to another photo, and no longer reads it three times.
- The sitemap listed seven `/admin/` URLs that only exist on the admin host.
- The four FrameLedger screenshots have text alternatives (content repository).
## [2.1.2] — 2026-11-09
### Security
@@ -164,7 +218,8 @@ The public launch is tagged `v1-launch`; the 1.x changes after it were not tagge
- **2026-10** — Custom Worker entry in front of every page; Workers Rate Limiting; Web Analytics;
topic email aliases; R2 media; the Turnstile gate; the admin at `admin.poli0981.dev`.
[Unreleased]: https://github.com/poli0981/poli0981-dev/compare/v2.1.2...HEAD
[Unreleased]: https://github.com/poli0981/poli0981-dev/compare/v2.2.0...HEAD
[2.2.0]: https://github.com/poli0981/poli0981-dev/compare/v2.1.2...v2.2.0
[2.1.2]: https://github.com/poli0981/poli0981-dev/compare/v2.1.1...v2.1.2
[2.1.1]: https://github.com/poli0981/poli0981-dev/compare/v2.1.0...v2.1.1
[2.1.0]: https://github.com/poli0981/poli0981-dev/compare/v2.0.0...v2.1.0
+10 -1
View File
@@ -20,7 +20,7 @@ the SkullMute channel, in Vietnamese and English. Live at **[poli0981.dev](https
| Content | Markdown/MDX in [`poli0981/content`](https://github.com/poli0981/content) (git submodule `src/content`) |
| Search | Pagefind (built after `astro build`) |
| Tooling | Node 26 · TypeScript 7 (`tsc`) next to TypeScript 6 (astro check, typescript-eslint) · `node:test` · ESLint · Prettier · knip |
| Quality | SonarCloud quality gate · CodeQL · OSV-Scanner · Snyk · Dependabot (3-day cooldown) |
| Quality | SonarCloud quality gate · CodeQL · OSV-Scanner · Snyk · Dependabot (3-day cooldown) · axe-core accessibility gate |
## How it fits together
@@ -65,6 +65,7 @@ identity (`dev@localhost`); saving content needs a `GITHUB_CONTENT_TOKEN` in `.d
| `npm run lint` · `npm run format:check` · `npm run knip` | ESLint · Prettier · unused files/exports |
| `npm test` · `npm run test:coverage` | `node:test` suites; coverage writes `coverage/lcov.info` (80% line floor) |
| `npm run smoke` | Runs the built Worker with `wrangler dev` and probes pages, headers, the gate and the denylist |
| `npm run test:a11y` | axe-core, keyboard, reflow and forced-colours checks against `npm run preview` (Chrome) |
| `npm run probe:ratelimit -- [url] [requests] [parallel]` | Spams a live URL and counts 429s from the Worker's site-wide limit vs. the WAF rule |
| `npm run new:post` | Scaffold a post or story from `docs/templates/` |
| `npm run check-exif` · `npm run strip-exif` | Refuse / remove GPS and camera metadata in images |
@@ -92,6 +93,14 @@ JWT (≤ 24 hours old) and an email allowlist on every request.
Please report vulnerabilities privately — see [`SECURITY.md`](SECURITY.md). Bug reports from the
site's "Report a bug" button land in a private repository, not in this one's issues.
## Accessibility
The site aims for WCAG 2.2 AA and checks it on every pull request (axe-core over every page, plus
keyboard, reflow and forced-colours tests). What is in place, what is known not to work and how to
report a barrier: [`ACCESSIBILITY.md`](ACCESSIBILITY.md); the statement for visitors is at
[`/legal/accessibility`](https://poli0981.dev/legal/accessibility/). Barriers can be reported to
**accessibility@poli0981.dev**.
## License
- **Code**: [GPL-3.0-only](LICENSE).
+6 -4
View File
@@ -14,7 +14,7 @@ CI fails if it drifts (docs 08 §6). Edit the script, not the block.
Generated by `scripts/gen-notices.mjs` from `package-lock.json`. CI fails if this
block drifts, so do not edit it by hand.
## Direct dependencies (34)
## Direct dependencies (36)
`runtime` are declared in `dependencies`; `build` in `devDependencies` and never served.
@@ -26,6 +26,7 @@ block drifts, so do not edit it by hand.
| `@astrojs/rss` | MIT | runtime |
| `@astrojs/sitemap` | MIT | runtime |
| `@astrojs/svelte` | MIT | runtime |
| `@axe-core/playwright` | MPL-2.0 | build |
| `@resvg/resvg-js` | MPL-2.0 | build |
| `@tailwindcss/vite` | MIT | runtime |
| `@types/node` | MIT | build |
@@ -40,6 +41,7 @@ block drifts, so do not edit it by hand.
| `lefthook` | MIT | build |
| `marked` | MIT | runtime |
| `pagefind` | MIT | build |
| `playwright` | Apache-2.0 | build |
| `prettier` | MIT | build |
| `prettier-plugin-astro` | MIT | build |
| `prettier-plugin-svelte` | MIT | build |
@@ -60,9 +62,9 @@ block drifts, so do not edit it by hand.
| License | Packages |
| ------- | -------- |
| MIT | 26 |
| Apache-2.0 | 3 |
| Apache-2.0 | 4 |
| MPL-2.0 | 3 |
| ISC | 2 |
| MPL-2.0 | 2 |
| MIT OR Apache-2.0 | 1 |
Transitive dependencies are deliberately not tallied here. Which packages get installed
@@ -72,7 +74,7 @@ inventory is `package-lock.json`; platform binaries are covered in prose below.
## Licenses outside the standard allowlist
**MPL-2.0** — 2 package(s): `@resvg/resvg-js`, `satori`
**MPL-2.0** — 3 package(s): `@axe-core/playwright`, `@resvg/resvg-js`, `satori`
> Reviewed: File-level copyleft. satori and @resvg/resvg-js are used unmodified as build-time tools and never shipped to the browser, so no source-disclosure obligation is triggered.
+4 -2
View File
@@ -10,8 +10,10 @@ import { rename, rmdir } from "node:fs/promises";
import { DEFAULT_LOCALE, LOCALES } from "./src/i18n/routing.ts";
import { THEME_BOOTSTRAP } from "./src/lib/theme.ts";
// Error/system pages that must never appear in the sitemap.
const NON_INDEXED = /\/(404|500|403|429|offline)\/?$/;
// Error/system pages that must never appear in the sitemap — and the admin's routes, which
// only exist on admin.poli0981.dev (on this host they answer 301/403) but were listed
// because they are prerendered shells like any other page.
const NON_INDEXED = /\/(404|500|403|429|offline)\/?$|^https?:\/\/[^/]+\/admin(\/|$)/;
// Sitemap <lastmod>. Every deploy is a full rebuild, so build time is the truthful
// "as of" for the whole site.
+156 -99
View File
@@ -14,18 +14,19 @@
"@astrojs/rss": "^4.0.19",
"@astrojs/sitemap": "^3.7.4",
"@astrojs/svelte": "^9.1.2",
"@tailwindcss/vite": "^4.3.4",
"@tailwindcss/vite": "^4.3.5",
"astro": "^7.4.7",
"jose": "^6.2.15",
"marked": "^18.1.3",
"sharp": "^0.35.5",
"svelte": "^5.57.3",
"tailwindcss": "^4.3.4",
"tailwindcss": "^4.3.5",
"yaml": "^2.9.1",
"zod": "^4.6.7"
},
"devDependencies": {
"@astrojs/check": "^0.9.12",
"@axe-core/playwright": "^4.14.0",
"@resvg/resvg-js": "^2.6.2",
"@types/node": "^26.6.6",
"@typescript/native": "npm:typescript@^7.0.2",
@@ -36,6 +37,7 @@
"knip": "^6.44.1",
"lefthook": "^2.2.2",
"pagefind": "^1.6.0",
"playwright": "^1.65.0",
"prettier": "^3.9.10",
"prettier-plugin-astro": "^0.14.1",
"prettier-plugin-svelte": "^4.1.1",
@@ -513,6 +515,22 @@
"yaml": "^2.8.3"
}
},
"node_modules/@axe-core/playwright": {
"version": "4.14.0",
"resolved": "https://registry.npmjs.org/@axe-core/playwright/-/playwright-4.14.0.tgz",
"integrity": "sha512-SGUhG5PIHd2eMdpgBF2PyQLOhX+qyDR2PT4cmoS4Qk2ak+jX/rrSvst9l0PGv5WTHolKpUMvVmoHpr4cZgf1RQ==",
"dev": true,
"license": "MPL-2.0",
"dependencies": {
"axe-core": "~4.14.0"
},
"engines": {
"node": ">=22.12.0"
},
"peerDependencies": {
"playwright-core": ">= 1.0.0"
}
},
"node_modules/@babel/helper-string-parser": {
"version": "7.29.13",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.13.tgz",
@@ -3919,9 +3937,9 @@
}
},
"node_modules/@tailwindcss/node": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.3.4.tgz",
"integrity": "sha512-b7QK/QG04v3j04NbpG82XLCedRyulnkuwUDwRa9oK/ypnJIzMapz2Wg+0TltVczjUzDaJJHIa1+jj9aMUOFMTQ==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.3.5.tgz",
"integrity": "sha512-yT53FzV4ke0cr/BguDxhWMpm5MJu1O2muzk+tKw6lKHjODAsYArBbWwFbJiaksfzFv1tpkO9QHGzmfs1hJT66g==",
"license": "MIT",
"dependencies": {
"@jridgewell/remapping": "^2.3.5",
@@ -3930,36 +3948,36 @@
"lightningcss": "1.33.0",
"magic-string": "^1.1.0",
"source-map-js": "^1.2.1",
"tailwindcss": "4.3.4"
"tailwindcss": "4.3.5"
}
},
"node_modules/@tailwindcss/oxide": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.3.4.tgz",
"integrity": "sha512-riqsRw2sLF7B1sNCCkTl3KYXEqvhTiABzZ/4oxxHfZ3c3Td60bCBfOrUuUGOiHagd3E7V+zG46c+XBDWZGFBcg==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.3.5.tgz",
"integrity": "sha512-PynqGLZsZvwM9tqD/CUxkOIfyd6K5elZ2MooauzJryP/UqXYgi3yYbtt3N0Xe+MHV/eFKPFQCEfIKAqlAS1CBg==",
"license": "MIT",
"engines": {
"node": ">= 20"
},
"optionalDependencies": {
"@tailwindcss/oxide-android-arm64": "4.3.4",
"@tailwindcss/oxide-darwin-arm64": "4.3.4",
"@tailwindcss/oxide-darwin-x64": "4.3.4",
"@tailwindcss/oxide-freebsd-x64": "4.3.4",
"@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.4",
"@tailwindcss/oxide-linux-arm64-gnu": "4.3.4",
"@tailwindcss/oxide-linux-arm64-musl": "4.3.4",
"@tailwindcss/oxide-linux-x64-gnu": "4.3.4",
"@tailwindcss/oxide-linux-x64-musl": "4.3.4",
"@tailwindcss/oxide-wasm32-wasi": "4.3.4",
"@tailwindcss/oxide-win32-arm64-msvc": "4.3.4",
"@tailwindcss/oxide-win32-x64-msvc": "4.3.4"
"@tailwindcss/oxide-android-arm64": "4.3.5",
"@tailwindcss/oxide-darwin-arm64": "4.3.5",
"@tailwindcss/oxide-darwin-x64": "4.3.5",
"@tailwindcss/oxide-freebsd-x64": "4.3.5",
"@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.5",
"@tailwindcss/oxide-linux-arm64-gnu": "4.3.5",
"@tailwindcss/oxide-linux-arm64-musl": "4.3.5",
"@tailwindcss/oxide-linux-x64-gnu": "4.3.5",
"@tailwindcss/oxide-linux-x64-musl": "4.3.5",
"@tailwindcss/oxide-wasm32-wasi": "4.3.5",
"@tailwindcss/oxide-win32-arm64-msvc": "4.3.5",
"@tailwindcss/oxide-win32-x64-msvc": "4.3.5"
}
},
"node_modules/@tailwindcss/oxide-android-arm64": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.3.4.tgz",
"integrity": "sha512-qkjxt+EFocOi3mtsUS3ndlj6yj4SHubwBdvBynLnS8T4mvSzX0Enn0CpypJKmBEtczUAXOHVZKA2zTGzSNU2Sg==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.3.5.tgz",
"integrity": "sha512-Se0z5xMqcSQanJD1IYmO0cGpK3iv0fp3ZsIT7xRJZ1Da5PghvNoc46zz4jIQn+aan3dV9T8AermFNN9QPmsh0Q==",
"cpu": [
"arm64"
],
@@ -3973,9 +3991,9 @@
}
},
"node_modules/@tailwindcss/oxide-darwin-arm64": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.3.4.tgz",
"integrity": "sha512-i/awUA/7mJQAbA3AzCW8aQtUh5goMieUdF1zOoclLaJUCxDvsXQ8VJqpQZY3dfcHS6PJjd3tw25nNneD/mEviQ==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.3.5.tgz",
"integrity": "sha512-UPrgTDuUbvmqGMZuCnmI3FKee/tYKzKdp00/kuB4oSGB213VYg8QTdF7lVhnPoBXq/mIfJ+ILoBFqNOboWcMwQ==",
"cpu": [
"arm64"
],
@@ -3989,9 +4007,9 @@
}
},
"node_modules/@tailwindcss/oxide-darwin-x64": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.3.4.tgz",
"integrity": "sha512-q56V9U6AnoYz/yj/alkDLhSQ9AZoXQSEl93f7WETa0+32CudbqM57BXdYXfMYPKudueXKaA+MG6L/0KRseF7Jg==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.3.5.tgz",
"integrity": "sha512-E+p7HEtjI0b8D7kbbWxH067cGui6d4c79COGko9fAPVE3rwc1E7ld2HFCbaG86AOGWS5VKQYqZOaf38ya4uxTQ==",
"cpu": [
"x64"
],
@@ -4005,9 +4023,9 @@
}
},
"node_modules/@tailwindcss/oxide-freebsd-x64": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.3.4.tgz",
"integrity": "sha512-r0W7A+Z9HTHh7bwihJl45E/zZKLjxD50/jToVF/E/RZHSl8+EWO+4yKKJpPMcUooT9hdoip3Zx1uWnbMg4N79g==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.3.5.tgz",
"integrity": "sha512-yWEWcWyAG7rWOcTpJTjdhQ3pcaFY2h+0bqTRfgU3G2fz87ZU3AKdvdZKhslD+kyHnjBUWKvNdRYwIYC5dI1tIg==",
"cpu": [
"x64"
],
@@ -4021,9 +4039,9 @@
}
},
"node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.3.4.tgz",
"integrity": "sha512-3aih/sRxzeYfi2Bkh+bGYNf2YU9Llamb2mpA7BNF1obYzdgEeWDAMQzK6BSwzLhs/eTdOaSur92qrGfchagUtQ==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.3.5.tgz",
"integrity": "sha512-WmeVjtJhZlr+smpqcdR2kQkkn6arHIJnUIBxTO2EJcTLGY1ecVXNo2hbSn8xc0IH2aEtys936iMWKGyj0GaKnA==",
"cpu": [
"arm"
],
@@ -4037,9 +4055,9 @@
}
},
"node_modules/@tailwindcss/oxide-linux-arm64-gnu": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.3.4.tgz",
"integrity": "sha512-ktJSrPGQou4OqL88rDEx5CkeM9BjzrwZvYo8u7B7VL1zkBa2XBm351o4MQrek95qikb2M++26Y7w7vbH6Mgl8g==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.3.5.tgz",
"integrity": "sha512-DTCSyucc6ShMp1QMqV5R94Z7xlgNgUzkGmFF1rL5HH2Qjy4eSmEqy+YLGkqqYvWa4sILtgrBt1JjRKbneQtiFQ==",
"cpu": [
"arm64"
],
@@ -4056,9 +4074,9 @@
}
},
"node_modules/@tailwindcss/oxide-linux-arm64-musl": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.3.4.tgz",
"integrity": "sha512-rt3hjUxT7utAtcB+df6wHyaXDyxhE7Zd1x7L/nvB5Jb2qBb8dZwFUoWqeRja1BaF5OlSqkKSjBmVXj9OsevmCQ==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.3.5.tgz",
"integrity": "sha512-H9lsvO4x9E4nE4Hi8h7NHHw0O/kcVSu+iOyFHNGdYzazGgDjFHZbE6S3hQ8kMcbNXSBlMdNi67LV5EVqtpaJtw==",
"cpu": [
"arm64"
],
@@ -4075,9 +4093,9 @@
}
},
"node_modules/@tailwindcss/oxide-linux-x64-gnu": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.3.4.tgz",
"integrity": "sha512-XE3jO2yOOWjttpeGvpwf3/b274NMi3QapQSAI/EzsgrmYNan1Tw8dXT9JQkN7K0OgvuqiC8mcCyNvGzEkpVJPQ==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.3.5.tgz",
"integrity": "sha512-4uxQvtBvPuIdl13WfUBj9xMZHH14PtHZ8OZdtLmdyDtG66sCa1t599NZT+jagkUzRtWhuul1qRZQ1nAJscXN5g==",
"cpu": [
"x64"
],
@@ -4094,9 +4112,9 @@
}
},
"node_modules/@tailwindcss/oxide-linux-x64-musl": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.3.4.tgz",
"integrity": "sha512-PaAZ2FjJaZk9SQLYtKIfQWiFm/xtl7pX2MKPgCzn0mS/VU54yu+vP457AJdB2XFLxU3gO2abLCt8N7Lg4EbKNg==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.3.5.tgz",
"integrity": "sha512-0JQAzs7jwbA7O6+z/adU+Jk3AXwsu3npAhtr5escXS7TqEqWcaDV7qHuI+0Vy/KQRuVGnLQREcSJWYauyV3oqg==",
"cpu": [
"x64"
],
@@ -4113,9 +4131,9 @@
}
},
"node_modules/@tailwindcss/oxide-wasm32-wasi": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.3.4.tgz",
"integrity": "sha512-bjO9WmoM687p8AoCIyw1DUqzpAs4JICLvNmIPxIWDmhw8IOsdubtWQLShyJmISnDKtRy1BBApHVOUl6sNFQQJA==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.3.5.tgz",
"integrity": "sha512-OJhFmlEfdzMr+avACdi40RPtnkW0B6hXyxL/8r+tnEHBWZji36CYRjEXrrvgBmaYsD3oEOBqwYFRKsYvzFe7Bw==",
"bundleDependencies": [
"@napi-rs/wasm-runtime",
"@emnapi/core",
@@ -4202,9 +4220,9 @@
"optional": true
},
"node_modules/@tailwindcss/oxide-win32-arm64-msvc": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.3.4.tgz",
"integrity": "sha512-jCrwCvWVtt7ruMXp6dFPd5KBNU8o1tWtEdZbTL/w/hvD3lUYZA0E2mmfvTzW4QLHIx5wGQU9HeY7997R1QTrEg==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.3.5.tgz",
"integrity": "sha512-9o8jgthi+QE5eandnboiJT64VQfnIArfZzSTdgbhEK5aafdiu2jTW9Honi/mwYHxBZuH1vAC57IFyrh+0iK5Gg==",
"cpu": [
"arm64"
],
@@ -4218,9 +4236,9 @@
}
},
"node_modules/@tailwindcss/oxide-win32-x64-msvc": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.3.4.tgz",
"integrity": "sha512-cge1wcedn1FrRSXL22lF5sNDYr8c9+VImk7zFYLPs12jkDmchSrZNfzWqOKub+5Hb/aYRdDEqERGGDKONBlOzQ==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.3.5.tgz",
"integrity": "sha512-XiKFfIy1RWe7qK4WqByxNW7Oz1/nkOy8o/BWhHminyV1PmpUd8Eedj5v2A8h2kpqeVlz6xRnwk9Fr/ZXNLcZfg==",
"cpu": [
"x64"
],
@@ -4234,14 +4252,14 @@
}
},
"node_modules/@tailwindcss/vite": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/vite/-/vite-4.3.4.tgz",
"integrity": "sha512-wGukGWb8SVuN7+FJvSS7M5eSJWDIWwVSvUvj1q41eTIhGPsS2DAgFWjA7YURJNwjHSgty59Hz8iMUiyO+YMHBQ==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@tailwindcss/vite/-/vite-4.3.5.tgz",
"integrity": "sha512-BCNiY0a1ZjdOHVqw7kyb7U72BwfMF3dfUuN+tQsLWky/J5JOI/r7abibglXfygrZhVO/3u3V+E25kkKTeMkXaQ==",
"license": "MIT",
"dependencies": {
"@tailwindcss/node": "4.3.4",
"@tailwindcss/oxide": "4.3.4",
"tailwindcss": "4.3.4"
"@tailwindcss/node": "4.3.5",
"@tailwindcss/oxide": "4.3.5",
"tailwindcss": "4.3.5"
},
"peerDependencies": {
"vite": "^5.2.0 || ^6 || ^7 || ^8"
@@ -4950,14 +4968,14 @@
"license": "ISC"
},
"node_modules/@volar/kit": {
"version": "2.4.30",
"resolved": "https://registry.npmjs.org/@volar/kit/-/kit-2.4.30.tgz",
"integrity": "sha512-VocLtumfXnqnPQEWc9Yx7uC1uOh9gyjVNlrn2+6Zx/z9aM6yTLhPK8lSqM9Ilu81XRa48I00lcYJWLi2BLxx8Q==",
"version": "2.4.31",
"resolved": "https://registry.npmjs.org/@volar/kit/-/kit-2.4.31.tgz",
"integrity": "sha512-pQgvegC28dfdNcs/iDNZVHkMs+dG7rpD9Aj+sNU2hildv1QuH7/MIoff/cSJW/IR25AGOeHWbJXWWFKDXXWtVw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@volar/language-service": "2.4.30",
"@volar/typescript": "2.4.30",
"@volar/language-service": "2.4.31",
"@volar/typescript": "2.4.31",
"typesafe-path": "^0.2.2",
"vscode-languageserver-textdocument": "^1.0.11",
"vscode-uri": "^3.0.8"
@@ -4967,25 +4985,25 @@
}
},
"node_modules/@volar/language-core": {
"version": "2.4.30",
"resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.30.tgz",
"integrity": "sha512-73fjwEV8wat6aOZ6U/y/hqtE30ocrIWECg67b0txGczOMNw+MffLmvJ5fnFfN9drVUEYZzLdaNo6VAy6G6avMw==",
"version": "2.4.31",
"resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.31.tgz",
"integrity": "sha512-OM+OZfynHa1/4WlC8klqvwTQVmhYUZuwpAKdfl/rlvK8jaIozMD5qwXsOkxcRJA2tC+TEFsG1K81lNP4s/IAzQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@volar/source-map": "2.4.30"
"@volar/source-map": "2.4.31"
}
},
"node_modules/@volar/language-server": {
"version": "2.4.30",
"resolved": "https://registry.npmjs.org/@volar/language-server/-/language-server-2.4.30.tgz",
"integrity": "sha512-tcP9fzzUBbsLIFHhgnRU4ncQjMn9G9Vax0ffkQmdCrXVEYqRroUepmyC5AVgiju5bCiLD6a55qen5iOTQHkb3g==",
"version": "2.4.31",
"resolved": "https://registry.npmjs.org/@volar/language-server/-/language-server-2.4.31.tgz",
"integrity": "sha512-PI/3CLcoHzb3RUNuh3ecWEf3d3doGnJ7/dYTvvE+8Y9dnV2SjVXp6BP7G2S5mdq9L1yFYP5yhoEHXc1OIfmX0A==",
"dev": true,
"license": "MIT",
"dependencies": {
"@volar/language-core": "2.4.30",
"@volar/language-service": "2.4.30",
"@volar/typescript": "2.4.30",
"@volar/language-core": "2.4.31",
"@volar/language-service": "2.4.31",
"@volar/typescript": "2.4.31",
"path-browserify": "^1.0.1",
"request-light": "^0.7.0",
"vscode-languageserver": "^9.0.1",
@@ -5003,13 +5021,13 @@
}
},
"node_modules/@volar/language-service": {
"version": "2.4.30",
"resolved": "https://registry.npmjs.org/@volar/language-service/-/language-service-2.4.30.tgz",
"integrity": "sha512-w/xDsASiqC71ggCOm7sTDXDNk/l72XEptodeRC68tgZ0e5QM4hM3zAqBGC7mBctvhrpYwKfMG+t9xcUo2hEFtA==",
"version": "2.4.31",
"resolved": "https://registry.npmjs.org/@volar/language-service/-/language-service-2.4.31.tgz",
"integrity": "sha512-LM9HFsBVhHZ7RbFUZK9P23FvamK8XCDcN0kNgOTts02wVgnygo3ReLbmBmUZ3GuYnrYn6HHoQvqk/eHIzzTnrg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@volar/language-core": "2.4.30",
"@volar/language-core": "2.4.31",
"vscode-languageserver-protocol": "^3.17.5",
"vscode-languageserver-textdocument": "^1.0.11",
"vscode-uri": "^3.0.8"
@@ -5024,21 +5042,21 @@
}
},
"node_modules/@volar/source-map": {
"version": "2.4.30",
"resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.30.tgz",
"integrity": "sha512-zym1ob/KwDDyN+0jGVtxwbxJSRRnUvv5HspCtz3yEfVVdCG4/dzxJktMGPAgemqRuVs81O0o/y0q3qOUErR8kg==",
"version": "2.4.31",
"resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.31.tgz",
"integrity": "sha512-odi31S3mKm57aO7Pd5P624FmGIB49U4lUPnYRUKvCDa8WZy5N5Yb+GMp2WJNaeIr4+q0ijNpuHsJLrfEiWvHtA==",
"dev": true,
"license": "MIT"
},
"node_modules/@volar/typescript": {
"version": "2.4.30",
"resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.30.tgz",
"integrity": "sha512-/DgA5tgYFPfrLFuSjIMXMGHk1LQv2+P8eny6+BhGNzFJELWIW7UZlc56ZLIRFhLsPpMfIFxM8/HvOPBggrjTZg==",
"version": "2.4.31",
"resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.31.tgz",
"integrity": "sha512-OBHLLAi03AmaRWqzytdFhgtW2B3HM+2/vXFkvnZAlEKltalUTyu+No7g9aZx7e9efrDLOtHsd/3PgCHSfgVJ/Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"@volar/language-core": "2.4.30",
"@volar/language-service": "2.4.30",
"@volar/language-core": "2.4.31",
"@volar/language-service": "2.4.31",
"path-browserify": "^1.0.1",
"vscode-uri": "^3.0.8"
},
@@ -5328,6 +5346,16 @@
"node": ">=12.20.0"
}
},
"node_modules/axe-core": {
"version": "4.14.0",
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.14.0.tgz",
"integrity": "sha512-9WTZxEjsZ7b13TH8JPmbV2z8CHbl80/2hm3XPEG4JgNdQLK81IBRXmSxHfMAOkSqQeRxT/0dwNDz2GOm3zzpcQ==",
"dev": true,
"license": "MPL-2.0",
"engines": {
"node": ">=4"
}
},
"node_modules/axobject-query": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz",
@@ -8114,6 +8142,35 @@
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/playwright": {
"version": "1.65.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.0.tgz",
"integrity": "sha512-F3AMWcR44qMBt4kq+6Kb6mX7bjGXshktKFOPULd7reED6ZJWevjbNRqysP7q+AATE9kdPEZBibex1BYsvpVoeA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "1.65.0"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=20"
}
},
"node_modules/playwright-core": {
"version": "1.65.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.0.tgz",
"integrity": "sha512-vNSKgH6YqtN7cdT/L334zo0a+YwkrpicyrHJlWWPIm/Q+Nn2SWInil01oT0mbu96U4GgoRtCYQD9CzJQgju+lA==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"playwright-core": "cli.js"
},
"engines": {
"node": ">=20"
}
},
"node_modules/postcss": {
"version": "8.5.32",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.32.tgz",
@@ -9136,9 +9193,9 @@
}
},
"node_modules/tailwindcss": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.4.tgz",
"integrity": "sha512-PCJZTFFdG+sL3gvnP1Do9o6GbkvH2q0p04xSs3f7cSvmAeK+sttG+/7ncK1fdRwKFfC7n+wDDJaOMBSefkI9ow==",
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.5.tgz",
"integrity": "sha512-FcQk9BuffmEHJP2G0XmB2SplU1aLTI7j07Kunk+U74Ny+XiWOtzXz9aujFZ/avntw1e2cOv/3PkgzflQ7gX2vQ==",
"license": "MIT"
},
"node_modules/tapable": {
@@ -9195,9 +9252,9 @@
}
},
"node_modules/tinyps": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/tinyps/-/tinyps-0.5.1.tgz",
"integrity": "sha512-B6Ykif5HflC3AdDkS4Zst/2muYVfeXoVMy+KorqH80s/1x4vunIORpNySH681X7fjj+dFM9MDKD6/Hsccjb87Q==",
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/tinyps/-/tinyps-0.5.2.tgz",
"integrity": "sha512-sYhvdbpuo2rGE7u/jPUMiZz4H2LCaOodUtRD9ot4DLNFQbr884g9zozoJnxLI+1r4hXqWkmdHUl8Yig2Rllxxw==",
"license": "MIT"
},
"node_modules/trim-lines": {
@@ -9618,9 +9675,9 @@
}
},
"node_modules/vfile-message": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.3.tgz",
"integrity": "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==",
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.4.tgz",
"integrity": "sha512-66ycRswIkNmHH9PHku7ADtv5RVwgIrOcuv3J8Svz6h4qgGRrKVa+9/neuKyJZUXyOpYwLTvS+whZ4R2urHHgQg==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
+5 -2
View File
@@ -22,6 +22,7 @@
"test": "node --import ./tests/support/register.mjs --test \"tests/**/*.test.ts\"",
"pretest:coverage": "node -e \"require('node:fs').mkdirSync('coverage', { recursive: true })\"",
"test:coverage": "node --import ./tests/support/register.mjs --test --experimental-test-coverage --test-coverage-include=\"src/**/*.ts\" --test-coverage-include=\"workers/widgets/src/**/*.ts\" --test-coverage-exclude=\"**/*.d.ts\" --test-coverage-exclude=\"src/lib/easter.ts\" --test-coverage-exclude=\"src/content.config.ts\" --test-coverage-lines=80 --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info \"tests/**/*.test.ts\"",
"test:a11y": "node --test --test-concurrency=1 \"tests/a11y/*.spec.ts\"",
"gen-notices": "node scripts/gen-notices.mjs",
"new:post": "node scripts/new-post.mjs",
"gen-og": "node scripts/gen-og.mjs",
@@ -54,18 +55,19 @@
"@astrojs/rss": "^4.0.19",
"@astrojs/sitemap": "^3.7.4",
"@astrojs/svelte": "^9.1.2",
"@tailwindcss/vite": "^4.3.4",
"@tailwindcss/vite": "^4.3.5",
"astro": "^7.4.7",
"jose": "^6.2.15",
"marked": "^18.1.3",
"sharp": "^0.35.5",
"svelte": "^5.57.3",
"tailwindcss": "^4.3.4",
"tailwindcss": "^4.3.5",
"yaml": "^2.9.1",
"zod": "^4.6.7"
},
"devDependencies": {
"@astrojs/check": "^0.9.12",
"@axe-core/playwright": "^4.14.0",
"@resvg/resvg-js": "^2.6.2",
"@types/node": "^26.6.6",
"@typescript/native": "npm:typescript@^7.0.2",
@@ -76,6 +78,7 @@
"knip": "^6.44.1",
"lefthook": "^2.2.2",
"pagefind": "^1.6.0",
"playwright": "^1.65.0",
"prettier": "^3.9.10",
"prettier-plugin-astro": "^0.14.1",
"prettier-plugin-svelte": "^4.1.1",
+3 -2
View File
@@ -29,9 +29,9 @@
| 16 | 16_COST.md | Chi phí chốt + ngưỡng cần theo dõi |
| 17 | 17_MAINTENANCE.md | Lịch bảo trì, update playbook, backup |
`12_LEGAL/`: `TERMS_OF_USE.md` · `PRIVACY_POLICY.md` · `DISCLAIMER.md` · `THIRD_PARTY_NOTICES.md` · `CONTENT_LICENSE.md` — **bản nháp gốc** (07/2026). Văn bản đang hiệu lực là `legal/*.md` trong repo `poli0981/content` (render ở `/legal/*`); sửa ở đó, không sửa ở đây.
`12_LEGAL/`: `TERMS_OF_USE.md` · `PRIVACY_POLICY.md` · `DISCLAIMER.md` · `THIRD_PARTY_NOTICES.md` · `CONTENT_LICENSE.md` — **bản nháp gốc** (07/2026). Văn bản đang hiệu lực là `legal/*.md` trong repo `poli0981/content` (render ở `/legal/*`); sửa ở đó, không sửa ở đây. Hai trang thêm sau (`ai-usage`, `accessibility`) chỉ có ở repo content, không có bản nháp tại đây.
## Nhật ký quyết định (chốt 2026-07-17, cập nhật 2026-10-24)
## Nhật ký quyết định (chốt 2026-07-17, cập nhật 2026-11-10)
| # | Quyết định | Chọn |
|---|---|---|
@@ -54,6 +54,7 @@
| D17 | Toolchain (10/2026) | Node 26 · TypeScript 7 (`tsc` kiểm kiểu) chạy song song TypeScript 6 (astro check, typescript-eslint, svelte2tsx cần JS API) · test bằng `node:test` (không thêm deps) · SonarCloud phân tích qua CI (`08` §0) |
| D18 | Báo lỗi (10/2026) | Issue tạo ở repo **private** `poli0981/site-reports` (repo site đã public) — `10` §4 |
| D19 | Phát hành | Tag `vX.Y.Z` có ký GPG + GitHub Release + `CHANGELOG.md`; deploy vẫn là "merge `main`" (`08` §8) |
| D20 | Trợ năng (11/2026, v2.2.0) | Mục tiêu **WCAG 2.2 AA** — kim chỉ nam, không tự nhận đã được kiểm định. Tuyên bố cho khách ở `/legal/accessibility` (song ngữ, repo content); `ACCESSIBILITY.md` ở root là bản của repo kèm ghi chú cho người sửa code (trang site thắng nếu lệch). Rào cản báo về `accessibility@` hoặc nút "Báo lỗi". Cổng tự động: `npm run test:a11y` (axe-core + bàn phím + reflow + forced-colors, Playwright lái Chrome có sẵn) chạy trong check bắt buộc `build` (`08` §0, checklist ở `03` §8) — ngoại lệ có chủ đích của D17 "không thêm deps cho test" |
## Cách dùng suite
+2 -2
View File
@@ -45,7 +45,7 @@ Website cá nhân `poli0981.dev` cho Kokone: **portfolio dev + blog kiêm nhật
| /dev (/uses) | PC specs, tool stack, setup OBS/Resolve | P2 |
| /qa | FAQ tĩnh từ collection `faq` + khối "Liên hệ" trỏ /links và `contact@` | P1 |
| /links | Toàn bộ social (YouTube, Discord ×2, GitHub, Telegram, Bluesky, Mastodon, X, Facebook), icon + mô tả | P1 |
| /legal/* | 5 trang từ `12_LEGAL/`, song ngữ | P1 |
| /legal/* | 7 trang song ngữ: 5 trang gốc từ `12_LEGAL/` + `ai-usage` + `accessibility` (tuyên bố trợ năng, 11/2026) | P1 |
| Search | Pagefind, modal, lọc theo locale | P2 |
| Error/offline | 404/403/429/500/offline custom | P1 (mini-game P3) |
| Bug report | Nút footer → GitHub Issue + Discord | P2 |
@@ -54,7 +54,7 @@ Website cá nhân `poli0981.dev` cho Kokone: **portfolio dev + blog kiêm nhật
## 6. Yêu cầu phi chức năng
- **Hiệu năng**: xem `14_PERF_BUDGET.md` (LCP < 2.0s mobile 4G, Lighthouse ≥ 95).
- **A11y**: WCAG 2.1 AA cho contrast/focus/keyboard; `prefers-reduced-motion` được tôn trọng ở mọi animation.
- **A11y**: mục tiêu WCAG 2.2 AA (`ACCESSIBILITY.md`, `/legal/accessibility`): contrast/focus/keyboard, không dựa riêng vào màu, reflow tới 320px, `forced-colors`; `prefers-reduced-motion` được tôn trọng ở mọi animation. `npm run test:a11y` (axe-core + bàn phím) chặn PR.
- **i18n**: UI 100% song ngữ; nội dung theo bài; URL ổn định khi thêm locale mới.
- **SEO**: hreflang, sitemap, JSON-LD, OG image tự sinh (xem `13_SEO_RSS_OG.md`).
- **Bảo mật**: xem `06_SECURITY.md`; mọi phiên bản dependency không có CVE chưa vá ở thời điểm chốt.
+3 -3
View File
@@ -67,11 +67,11 @@ poli0981-dev/
│ ├── lib/ # gate/, admin/, media/, denylist, ext-img, log, version, palette, theme…
│ ├── pages/ # routes + /en/* + api/* + admin/* + 403/404/429/500
│ └── styles/ # global.css (token), prose.css, admin.css
├── tests/ # node:test + support/ (stub astro:*, fake KV/R2/GitHub…)
├── tests/ # node:test + support/ (stub astro:*, fake KV/R2/GitHub…) · a11y/ (*.spec.ts: axe-core + bàn phím qua Playwright)
├── workers/widgets/ # worker cron riêng (wrangler.jsonc riêng)
├── .github/ # ci.yml, content-bump.yml, lighthouse.yml, osv-scanner.yml, dependabot.yml
├── .github/ # ci.yml, content-bump.yml, lighthouse.yml, osv-scanner.yml, dependabot.yml, ISSUE_TEMPLATE/ (bug_report, accessibility), pull_request_template.md
├── astro.config.mjs · wrangler.jsonc · sonar-project.properties · lefthook.yml · knip.json
└── LICENSE (GPL-3.0) · CONTENT-LICENSE.md · DISCLAIMER.md · THIRD-PARTY-NOTICES.md · SECURITY.md · CHANGELOG.md
└── LICENSE (GPL-3.0) · CONTENT-LICENSE.md · DISCLAIMER.md · THIRD-PARTY-NOTICES.md · SECURITY.md · ACCESSIBILITY.md · CHANGELOG.md
```
## 4. Rendering & routing
+9 -4
View File
@@ -126,10 +126,15 @@ Token `--scrollbar-thumb` / `--scrollbar-thumb-hover` / `--scrollbar-track` khai
## 8. A11y & mobile checklist (áp cho mọi PR UI)
- Focus ring rõ (2px accent, offset 2px), điều hướng bàn phím đủ; skip-link.
- Touch target ≥ 44×44; `safe-area-inset` cho TabBar; không hover-only cho thông tin.
- Ảnh có alt (bắt buộc trong schema gallery); icon-only button có `aria-label`.
- Kiểm tra 360px, 390px, 768px, 960px, 1280px; dark/light/theo hệ thống; vi/en (chuỗi EN thường dài hơn ~20%).
- Focus ring rõ (2px accent, offset 2px), điều hướng bàn phím đủ; skip-link. Thứ gì mở ra (menu, dialog, panel) thì đóng bằng Esc và **trả focus về nút đã mở nó**.
- Focus không được nằm dưới thanh cố định (WCAG 2.4.11): `scroll-padding` của `html` (global.css) đã trừ header, TabBar, thanh đọc truyện và bảng thông báo pháp lý — thanh mới ở mép trên/dưới phải cộng vào `--subheader-h` / `--bottom-bar-h`.
- Touch target: TabBar 56px, icon mạng xã hội ở footer 44px, nút header 40px; **không bao giờ dưới 24px** (WCAG 2.5.8). `safe-area-inset` cho TabBar; không hover-only cho thông tin.
- Trạng thái và "đang ở đâu" **không chỉ bằng màu** (WCAG 1.4.1): nav đang mở có gạch chân, tab đang mở có vạch trên, lựa chọn đang chọn in đậm + viền kép; link nằm giữa câu phải gạch chân.
- `forced-colors` (Windows High Contrast): thứ chỉ vẽ bằng `background`/`box-shadow` sẽ biến mất — thêm `outline` hoặc màu hệ thống (`Highlight`, `ButtonText`, `Canvas`…) trong `@media (forced-colors: active)`.
- Ảnh có alt (bắt buộc trong schema gallery; `alt=""` chỉ khi ảnh trang trí); icon-only button có `aria-label` **bắt đầu bằng chữ đang hiển thị** (WCAG 2.5.3 — axe so theo từng từ và bỏ phần trong ngoặc đơn).
- Heading không nhảy cấp: card (`PostCard`/`ProjectCard`/`GalleryCard`) nhận `headingLevel` — 2 khi nằm ngay dưới `h1`, 3 khi dưới một `h2`. Mỗi `<nav>` một tên riêng (footer đã dùng "Pháp lý" và "Mạng xã hội").
- Kiểm tra 320px, 360px, 390px, 768px, 960px, 1280px (không cuộn ngang ở bất kỳ mức nào); zoom 200%; dark/light/theo hệ thống; vi/en (chuỗi EN thường dài hơn ~20% — header cần 378px ở bản vi, 400px ở bản en, dưới đó nút ngôn ngữ rút thành `EN`/`VI`).
- `npm run test:a11y` xanh (axe-core mọi trang + các dialog khi mở, bàn phím, reflow, forced-colors — `tests/a11y/`), rồi nghe lại một lượt bằng trình đọc màn hình. Cam kết đầy đủ: `ACCESSIBILITY.md`.
- Màu mới phải vào `palette.ts` + `global.css` cùng lúc (test chặn nếu lệch hoặc dưới AA); không hard-code màu trong component — dùng token.
- `<dialog>` modal giữ `margin: auto` (preflight Tailwind xoá margin — global.css trả lại); danh sách trong `.prose` có marker (preflight xoá `list-style`).
- Nhãn landmark, aria-label và chuỗi giao diện lấy từ `src/i18n`, không viết cứng.
+3 -3
View File
@@ -12,7 +12,7 @@
| `/gallery`, `/gallery/[album]` | `/en/...` | gallery |
| `/gaming` · `/dev` (kèm `/dev/uses`) | `/en/...` | md + widgets |
| `/qa` · `/links` | `/en/...` | faq + data links |
| `/legal/{terms,privacy,disclaimer,third-party,licenses,ai-usage}` | `/en/legal/...` | `legal/*.md` (repo content) |
| `/legal/{terms,privacy,disclaimer,third-party,licenses,ai-usage,accessibility}` | `/en/legal/...` | `legal/*.md` (repo content) |
| `/now` | `/en/now` | now |
| `/rss.xml`, `/blog/rss.xml`, `/truyen/rss.xml`, `/sitemap-index.xml`, `/robots.txt`, `/.well-known/security.txt` | | |
| `/404` (+ bản en cho mọi đường dẫn `/en/…`), `/500`, `/403`, `/429`, `/offline` | tiêu đề chính + dòng ngôn ngữ kia; 404 có bản riêng mỗi ngôn ngữ | 09 |
@@ -71,8 +71,8 @@ ReadingControls: cỡ chữ S/M/L · nền Giấy/Sepia/Tối (độc lập them
## 5. Legal gate — LegalGateSheet
- **Kích hoạt**: lần truy cập đầu (thiếu `localStorage.legalAck`), delay 800ms sau khi trang tương tác được; không hiện trên `/legal/*` và trang lỗi.
- **Hình thức**: bottom-sheet (mobile) / card góc phải dưới (desktop), chiếm ≤ 40% chiều cao, **không chặn scroll** — nội dung phía sau vẫn đọc được (SEO/crawler không ảnh hưởng vì chỉ là overlay client-side).
- **Nội dung** (song ngữ theo locale): 3 dòng — nội dung © Kokone; phần mềm/thương hiệu được nhắc tới thuộc chủ sở hữu tương ứng, site không liên kết; site dùng analytics không cookie. Link: Terms · Privacy · Disclaimer · Third-party · Licenses. Nút: **"Đã hiểu / Got it"** → `legalAck = {v:1, ts}`.
- **Hình thức**: bottom-sheet (mobile — nằm **trên** TabBar chứ không đè lên, để 4 nút của TabBar vẫn thấy và bấm được) / card góc phải dưới (desktop), chiếm ≤ 40% chiều cao, **không chặn scroll** — nội dung phía sau vẫn đọc được (SEO/crawler không ảnh hưởng vì chỉ là overlay client-side).
- **Nội dung** (song ngữ theo locale): 3 dòng — nội dung © Kokone; phần mềm/thương hiệu được nhắc tới thuộc chủ sở hữu tương ứng, site không liên kết; site dùng analytics không cookie. Link: cả 7 trang của `legalNav` (Terms · Privacy · Disclaimer · Third-party · Licenses · AI · Trợ năng). Nút: **"Đã hiểu / Got it"** → `legalAck = {v:1, ts}`. Sheet là landmark `complementary` có tên, công bố chiều cao của mình qua `--sheet-h` để focus phía sau không bị che (`03` §8).
- Đổi phiên bản văn bản legal lớn → tăng `v` để sheet hiện lại. Footer luôn có link legal (gate chỉ là lớp nhắc).
## 6. Copy & tone
+1
View File
@@ -104,6 +104,7 @@ Mail của domain chạy trên **Google Workspace** (MX → `aspmx.l.google.com`
| `contact@` | Liên hệ chung (fallback) | Footer, /links, /now, trang 403 |
| `security@` | Báo lỗ hổng | `/.well-known/security.txt`, `SECURITY.md` |
| `privacy@` | Yêu cầu về dữ liệu cá nhân | Privacy §7–8 |
| `accessibility@` | Báo rào cản trợ năng (trả lời ≤ 7 ngày) | `/legal/accessibility` §5, `ACCESSIBILITY.md`, issue template `accessibility.yml`, README |
| `legal@` | Vấn đề pháp lý | Terms |
| `copyright@` · `dmca@` · `takedown@` | Xin phép · khiếu nại bản quyền · yêu cầu gỡ khác | Licenses, `CONTENT-LICENSE.md` |
| `collab@` · `press@` · `sponsor@` | Hợp tác · báo chí · tài trợ | /links, Q&A, footer |
+2 -2
View File
@@ -4,7 +4,7 @@
- **Deploy**: Cloudflare **Workers Builds** nối repo (không có job deploy trong GitHub Actions): `main` → build + `npx wrangler deploy`; nhánh khác → `npx wrangler versions upload` (version preview, không nhận traffic). Cấu hình chi tiết + bẫy đã gặp: `07` §9.
- **`ci.yml`** (PR, push `main`, `workflow_dispatch`), job **`build`** (timeout 30 phút, checkout kèm submodule):
`npm ci --ignore-scripts` → `check-install-scripts` → `wrangler types` (site + widgets) → prettier → eslint → `astro check` (TS 6) → **`typecheck` bằng TypeScript 7** (in `tsc -v`, kiểm site + widgets) → knip → **`test:coverage`** (`node:test`, ngưỡng 80% dòng, xuất `coverage/lcov.info`) → `npm audit --omit=dev --audit-level=high` → `gen-notices --check` → `check-exif --changed` → build (+ OG, Pagefind, `check-csp-hashes`) → **smoke test** (`npm run smoke`: chạy worker đã build bằng `wrangler dev`, kiểm trang/304/HEAD/`/media`/`/ext-img`/admin 403/`frame-ancestors`, pha ép bật cổng Turnstile kể cả cookie sai định dạng, pha denylist) → upload coverage làm artifact. Check `build` là **bắt buộc** (ruleset `main`).
`npm ci --ignore-scripts` → `check-install-scripts` → `wrangler types` (site + widgets) → prettier → eslint → `astro check` (TS 6) → **`typecheck` bằng TypeScript 7** (in `tsc -v`, kiểm site + widgets) → knip → **`test:coverage`** (`node:test`, ngưỡng 80% dòng, xuất `coverage/lcov.info`) → `npm audit --omit=dev --audit-level=high` → `gen-notices --check` → `check-exif --changed` → build (+ OG, Pagefind, `check-csp-hashes`) → **smoke test** (`npm run smoke`: chạy worker đã build bằng `wrangler dev`, kiểm trang/304/HEAD/`/media`/`/ext-img`/admin 403/`frame-ancestors`, pha ép bật cổng Turnstile kể cả cookie sai định dạng, pha denylist) → **cổng trợ năng** (từ v2.2.0: `npm run preview` chạy nền rồi `npm run test:a11y` — Playwright lái Chrome có sẵn trên runner, không tải trình duyệt; axe-core quét mọi trang trong sitemap của bản build, một trang mỗi template ở theme sáng và bề rộng điện thoại, và menu/tìm kiếm/lightbox/hộp báo lỗi/bảng Aa/bảng pháp lý khi đang mở; sau đó là test bàn phím, reflow 320/360/390px và `forced-colors`) → upload coverage làm artifact. Check `build` là **bắt buộc** (ruleset `main`), nên PR có vi phạm axe không merge được.
- Job **`sonarcloud`** (sau `build`; chạy cho push `main` và PR cùng repo, bỏ qua Dependabot): tải coverage → `SonarSource/sonarqube-scan-action` (pin SHA) với `sonar-project.properties`; trên PR chờ **quality gate** ("Sonar way" cho new code: coverage ≥ 80%, trùng lặp ≤ 3%, rating A, hotspot đã review). Automatic analysis trên SonarCloud **tắt** (CI analysis thay thế); `SONAR_TOKEN` là secret của repo. `.svelte`/`.astro` không được Sonar phân tích — logic quan trọng nằm trong `.ts` để đo được.
- **CodeQL** (default setup, repo public) · **Snyk** (GitHub app) · **`osv-scanner.yml`** (reusable workflow v2.7.0, SARIF, hằng tuần + khi đổi lockfile) · **`lighthouse.yml`** (`treosh/lighthouse-ci-action` pin SHA, preset mobile, chỉ cảnh báo).
- **`content-bump.yml`** (nút **Xuất bản** của admin): trỏ submodule `src/content` về `content/main`, commit lên nhánh `content/bump`, mở/cập nhật PR, auto-merge (squash) nếu diff chỉ `.md/.json`, rồi `gh workflow run ci.yml --ref content/bump` để có check `build` (PR mở bằng GITHUB_TOKEN không kích hoạt `pull_request`). Merge ⇒ Workers Builds deploy.
@@ -118,6 +118,6 @@ Commit và tag đều ký GPG; không dùng `--no-verify`.
- `main` protected (ruleset): PR + check `build` xanh; merge kiểu **squash**. Conventional Commits.
- Mỗi PR: CI `build` + SonarCloud quality gate + CodeQL xanh trước khi merge; Workers Builds trên nhánh PR chỉ `versions upload`.
- **Release**: tag `vX.Y.Z` có ký GPG trên commit `main` đã deploy + GitHub Release (notes lấy từ `CHANGELOG.md`). Deploy vẫn là "merge `main`" — tag chỉ đánh dấu mốc. `v2.0.0` = đợt nâng cấp 10/2026.
- **Release**: tag `vX.Y.Z` có ký GPG trên commit `main` đã deploy + GitHub Release (notes lấy từ `CHANGELOG.md`). Deploy vẫn là "merge `main`" — tag chỉ đánh dấu mốc. `v2.0.0` = đợt nâng cấp 10/2026. Mỗi tag: sửa `sonar.projectVersion` trong `sonar-project.properties` cho khớp.
- Sau merge: kiểm `https://poli0981.dev/api/health` trả đúng commit (`07` §9); nếu Workers Builds không deploy thì promote version của `main` bằng `wrangler versions deploy`.
+1 -1
View File
@@ -16,7 +16,7 @@ Bài không có bản dịch: không render hreflang (tránh trỏ trang không
## 3. Sitemap & robots
- `@astrojs/sitemap` với `i18n` config → `sitemap-index.xml`; loại trang lỗi, `/offline`, trang draft.
- `@astrojs/sitemap` với `i18n` config → `sitemap-index.xml`; loại trang lỗi, `/offline`, trang draft và mọi route `/admin/*` (chỉ tồn tại trên `admin.poli0981.dev`; trước v2.2.0 bị lọt 7 URL vào sitemap). Bộ test trợ năng (`tests/a11y/`) lấy danh sách trang từ chính sitemap này.
- `public/robots.txt`:
```
+2
View File
@@ -38,6 +38,8 @@ Trạng thái tại 2026-10-24 (v2.0.0): ✅ xong · 🟡 đang làm · ⬜ chư
- Cổng Turnstile trước mọi trang (06 §3b) · admin `admin.poli0981.dev` (Access + JWT, R2 media, xuất bản qua workflow) · repo public.
- **v2.0.0**: Node 26 + TypeScript 7 · SonarCloud + test `node:test` (~99% dòng) · vá bypass cookie cổng · denylist CIDR · ảnh widget qua `/ext-img` · log JSON + version trên `/api/health` · báo lỗi vào repo private · palette Glacier Teal + theme theo hệ điều hành · sửa a11y/i18n · admin mới (tổng quan, hoạt động, bảo mật, audit log). Chi tiết: `CHANGELOG.md`.
- **v2.2.0** (11/2026): tuyên bố trợ năng (`/legal/accessibility` + `ACCESSIBILITY.md`, địa chỉ `accessibility@`) · cổng axe-core + bàn phím trong CI · hỗ trợ Windows High Contrast · "đang ở đâu" không chỉ bằng màu · sửa tràn ngang ở màn hình hẹp (reflow tới 320px) · focus không bị che dưới thanh cố định. Chi tiết: `CHANGELOG.md`, quyết định D20.
## P4 — Launch công khai 🟡
- [x] Checklist `06` §8 (security) phần tự động (headers, CSP, cổng)
+3 -1
View File
@@ -9,7 +9,7 @@ Mục tiêu: site "để yên vẫn sống". Tổng thời gian bảo trì đị
| **Hằng tuần** (thứ 2, sau khi Dependabot chạy) | Triage PR Dependabot: patch/minor xanh CI → merge; security alert → xử lý ≤ 48h. Liếc Discord `#site-reports` |
| **Hằng tháng** | `npm outdated` đọc report weekly; nâng minor còn sót; **nâng tay `@typescript/native`** (Dependabot bỏ qua alias `npm:`) và xem TS 7.1 đã có JS API chưa (`02` §8); xem Web Analytics + Core Web Vitals; liếc Workers Logs (lọc `level: error`) + dashboard admin (trạng thái cron widgets, secret thiếu); SonarCloud không có issue mới trên `main` |
| **Hằng quý** | Nâng major có kế hoạch (Astro/Tailwind/Wrangler — đọc upgrade guide trước); chạy lại ma trận error test `09` §5; backup ngoài (§4) |
| **Hằng năm** | **Xoay secrets**: GITHUB_ISSUES_TOKEN (repo `site-reports`), GITHUB_CONTENT_TOKEN + GITHUB_PUBLISH_TOKEN (admin), GATE_SECRET (vô hiệu mọi vé cổng — làm lúc ít khách), STEAM_API_KEY, SONAR_TOKEN · rà `ADMIN_EMAILS` + policy Access · cập nhật `Expires` trong security.txt · đọc lại 5 văn bản legal (đổi thì tăng `v` của legalAck) · kiểm tra thẻ thanh toán còn hạn cho auto-renew domain |
| **Hằng năm** | **Xoay secrets**: GITHUB_ISSUES_TOKEN (repo `site-reports`), GITHUB_CONTENT_TOKEN + GITHUB_PUBLISH_TOKEN (admin), GATE_SECRET (vô hiệu mọi vé cổng — làm lúc ít khách), STEAM_API_KEY, SONAR_TOKEN · rà `ADMIN_EMAILS` + policy Access · cập nhật `Expires` trong security.txt · đọc lại 7 trang legal (đổi thì tăng `v` của legalAck) · **rà trợ năng**: đọc lại `/legal/accessibility` + `ACCESSIBILITY.md`, đi một lượt bằng bàn phím và trình đọc màn hình, cập nhật ngày rà ở cả hai nơi · kiểm tra thẻ thanh toán còn hạn cho auto-renew domain |
Đặt reminder: dùng chính hệ notify/cron GitHub Actions quen thuộc — workflow cron tháng/quý/năm bắn Discord nhắc việc (input sẵn trong repo `.github`).
@@ -51,4 +51,6 @@ Mục tiêu: site "để yên vẫn sống". Tổng thời gian bảo trì đị
| Spam form vượt rate-limit thường xuyên | Nâng Turnstile lên chế độ khó hơn + thêm custom rule quốc gia cho /api |
| Version sai lên production (PR được deploy, regression) | Rollback ngay (§2), rồi kiểm Deploy command của Workers Builds (`07` §9) |
| Bị khoá ngoài admin (Access/`ADMIN_EMAILS`) | `wrangler secret put ADMIN_EMAILS` với email đúng; kiểm policy Access; denylist có chặn nhầm IP mình không (`wrangler kv key get … denylist`) |
| Có báo cáo rào cản trợ năng (`accessibility@`, nút Báo lỗi, issue nhãn `accessibility`) | Trả lời ≤ 7 ngày; lỗi chặn hẳn việc đọc/dùng trang làm trước; nói rõ định làm gì + cách tạm thời; sửa xong thì thêm test vào `tests/a11y/` và, nếu chưa sửa được, ghi vào "Known limitations" của `ACCESSIBILITY.md` + trang `/legal/accessibility` |
| Release có đổi giao diện | `npm run test:a11y` xanh + nghe lại các chỗ đã đổi bằng Narrator/VoiceOver; cập nhật "Last reviewed" trong `ACCESSIBILITY.md` |
| Đổi email/mất hộp thư đích | Cập nhật alias Google Workspace + `src/lib/links.ts` + security.txt + legal contact ngay (`07` §11) |
+3 -2
View File
@@ -4,14 +4,15 @@ sonar.organization=poli0981
sonar.projectKey=poli0981_poli0981-dev
sonar.projectName=poli0981-dev
# Bumped with each release tag; "previous version" new-code periods start from it.
sonar.projectVersion=2.1.1
sonar.projectVersion=2.2.0
sonar.sourceEncoding=UTF-8
# .github is analyzed too: the workflow rules (pinned actions, no npx/install scripts) are
# part of the supply-chain posture, not noise to exclude.
sonar.sources=src,workers/widgets/src,scripts,public,.github
sonar.tests=tests
sonar.test.inclusions=tests/**/*.test.ts
# *.spec.ts is the browser-driven accessibility suite (tests/a11y, `npm run test:a11y`).
sonar.test.inclusions=tests/**/*.test.ts,tests/**/*.spec.ts
# Not ours or not code: the content submodule (Markdown), photos, generated declaration
# files and the prebuilt search bundle.
+9 -2
View File
@@ -117,15 +117,22 @@ function relFor(href: string, me?: boolean): string | undefined {
.footer-legal a:hover {
color: var(--accent);
}
/* Each icon is 18px but its link is a 44px square (docs 03 §8; WCAG 2.5.8 asks for 24).
The negative margins take back the padding that adds, so the first icon still lines up
with the text above and the row keeps its height. */
.footer-social {
display: flex;
flex-wrap: wrap;
gap: 0.85rem;
align-items: center;
margin-block: 0.25rem;
margin-block: -0.5rem;
margin-inline-start: -0.8125rem;
}
.footer-social a {
display: inline-flex;
align-items: center;
justify-content: center;
min-inline-size: 2.75rem;
min-block-size: 2.75rem;
color: var(--muted);
transition: color var(--duration-fast) var(--ease-site);
}
+6 -2
View File
@@ -9,8 +9,12 @@ interface Props {
entry: GalleryEntry;
cover: GalleryPhoto;
locale: Locale;
/** Heading level of the card title: 3 under a section heading, 2 right under the
page's h1 (an index page) — heading levels must not skip. */
headingLevel?: 2 | 3;
}
const { entry, cover, locale } = Astro.props;
const { entry, cover, locale, headingLevel = 3 } = Astro.props;
const Title = `h${headingLevel}` as const;
const href = sectionPath("gallery", locale, entry.data.album);
const year = entry.data.date.getFullYear();
---
@@ -34,7 +38,7 @@ const year = entry.data.date.getFullYear();
}
</div>
<div class="body">
<h3 class="title">{entry.data.title}</h3>
<Title class="title">{entry.data.title}</Title>
<span class="year">{year}</span>
</div>
</a>
+17
View File
@@ -108,6 +108,10 @@ const pathname = Astro.url.pathname;
.brand {
display: inline-flex;
align-items: center;
/* As tall as the buttons beside it, and never narrower: once the wordmark is hidden
(below) the link would otherwise be the 32×12px mark alone. */
min-block-size: 2.5rem;
min-inline-size: 2.5rem;
gap: 0.5rem;
color: var(--text);
font-family: var(--ff-display);
@@ -119,6 +123,14 @@ const pathname = Astro.url.pathname;
block-size: 0.75rem;
color: var(--accent);
}
/* Down to a 320px viewport (WCAG 1.4.10 Reflow; also a desktop window at 400% zoom) the
header has no room for the wordmark: the mark alone stays, and the link keeps its
name through aria-label. */
@media (max-width: 21.99rem) {
.brand-text {
display: none;
}
}
.primary-nav {
display: none;
gap: 0.35rem;
@@ -138,8 +150,13 @@ const pathname = Astro.url.pathname;
color: var(--text);
background: var(--surface);
}
/* Colour is not the only cue for "you are here" (WCAG 1.4.1): the underline also
survives forced-colors mode, where the accent is replaced by the link colour. */
.primary-nav a[aria-current="page"] {
color: var(--accent);
text-decoration: underline;
text-decoration-thickness: 2px;
text-underline-offset: 0.45em;
}
.actions {
display: flex;
+34 -3
View File
@@ -13,6 +13,7 @@ const target: Locale = current === "vi" ? "en" : "vi";
const t = useTranslations(current);
const { href = alternatePath(Astro.url.pathname, target), label = t.lang.switchTo } = Astro.props;
const code = target.toUpperCase();
---
{
@@ -20,14 +21,24 @@ const { href = alternatePath(Astro.url.pathname, target), label = t.lang.switchT
voice control can act on what the user sees — WCAG 2.5.3 Label in Name (A).
`aria-label="Ngôn ngữ"` alone dropped it entirely. */
}
{
/* On a narrow phone the full name does not fit next to the brand and the three buttons
(the header needs 378px with "English", 400px with "Tiếng Việt"), and the page then
scrolled sideways. Below those widths the link shows the language code instead. The
accessible name carries both the name and the code as words of their own
("Tiếng Việt, VI — Language"), so it contains whichever of the two is on screen. axe
matches whole words and drops anything in parentheses: "VI" inside "Việt" does not
count, and neither would "(VI)". */
}
<a
class="lang-switch"
class:list={["lang-switch", `to-${target}`]}
{href}
hreflang={target}
lang={target}
aria-label={`${label} — ${t.lang.label}`}
aria-label={`${label}, ${code} — ${t.lang.label}`}
>
{label}
<span class="full">{label}</span>
<span class="short" aria-hidden="true">{code}</span>
</a>
<style>
@@ -52,4 +63,24 @@ const { href = alternatePath(Astro.url.pathname, target), label = t.lang.switchT
background: var(--surface);
border-color: var(--line);
}
.short {
display: none;
}
/* rem, so the switch-over moves with the reader's font size like the text it measures. */
@media (max-width: 23.99rem) {
.to-en .full {
display: none;
}
.to-en .short {
display: inline;
}
}
@media (max-width: 25.24rem) {
.to-vi .full {
display: none;
}
.to-vi .short {
display: inline;
}
}
</style>
+34 -3
View File
@@ -50,10 +50,38 @@
document.removeEventListener("keydown", onKey);
};
});
// The sheet does not take focus and sits at the end of the tab order, so someone tabbing
// through the page reaches controls that lie underneath it. Publish how much of the
// viewport's bottom it covers; the page's scroll padding (global.css) then keeps whatever
// receives focus above it (WCAG 2.4.11). The figure is the sheet's own height plus its
// gap to the bottom edge — laid-out sizes, so neither the slide-in transform nor how far
// the page is scrolled skews it. Set through CSSOM, never a style attribute (CSP).
$effect(() => {
if (!visible || !sheetEl) return;
const el = sheetEl;
const root = document.documentElement;
const sync = () => {
const gap = Number.parseFloat(getComputedStyle(el).bottom) || 0;
root.style.setProperty("--sheet-h", `${Math.round(el.offsetHeight + gap)}px`);
};
sync();
const observer = new ResizeObserver(sync);
observer.observe(el);
window.addEventListener("resize", sync);
return () => {
observer.disconnect();
window.removeEventListener("resize", sync);
root.style.removeProperty("--sheet-h");
};
});
</script>
{#if visible}
<aside bind:this={sheetEl} class="gate" role="note" aria-label={strings.label}>
<!-- A named complementary landmark (the <aside> itself): a screen-reader user can jump
to the notice from the landmark list instead of meeting it at the very end of the
page. role="note" is not a landmark and left the sheet outside every region. -->
<aside bind:this={sheetEl} class="gate" aria-label={strings.label}>
<div class="gate-body">
<p>{strings.line1}</p>
<p>{strings.line2}</p>
@@ -73,11 +101,14 @@
position: fixed;
z-index: 55;
inset-inline: 0;
inset-block-end: 0;
/* On a phone the sheet rests on top of the tab bar instead of covering it: the bar's
four controls stay visible and reachable while the notice is up (WCAG 2.4.11), and
the bar already pads for the home indicator. --bottom-bar-h is 0 from 768px up. */
inset-block-end: var(--bottom-bar-h, 0px);
/* Does NOT block scroll — no backdrop; only the card is interactive. */
max-block-size: 40vh;
overflow-y: auto;
padding: 1rem 1.15rem calc(1rem + env(safe-area-inset-bottom, 0));
padding: 1rem 1.15rem;
background: var(--elevated);
border-block-start: 1px solid var(--line);
box-shadow: var(--shadow-elevated);
+9 -2
View File
@@ -149,7 +149,11 @@
aria-describedby="lb-caption"
>
<div class="bar">
<span class="count" aria-live="polite">{counter}</span>
<!-- Arrowing to another photo announces its position and its caption: focus stays on
the button, so nothing else would say which photo is now showing. -->
<span class="count" aria-live="polite"
>{counter}<span class="sr-only"> — {current.alt}</span></span
>
<button type="button" class="close" onclick={close} aria-label={labels.close}>✕</button>
</div>
@@ -188,7 +192,10 @@
aria-label={labels.next}>›</button
>
<p class="caption" id="lb-caption">{current.alt}</p>
<!-- The same words are the image's alt and the dialog's description (aria-describedby
still resolves a hidden node), so the visible copy is hidden from the reading order
rather than read a third time. -->
<p class="caption" id="lb-caption" aria-hidden="true">{current.alt}</p>
</div>
{/if}
+4 -2
View File
@@ -112,8 +112,10 @@
</nav>
{#if legal.length}
<nav aria-labelledby="menu-sheet-legal">
<p id="menu-sheet-legal" class="group-title">{legalTitle}</p>
<!-- Named "Menu — Legal", not just "Legal": the footer's nav already has that name, and
two landmarks that sound the same cannot be told apart in a landmark list. -->
<nav aria-label={`${title} — ${legalTitle}`}>
<p class="group-title">{legalTitle}</p>
<ul class="links legal">
{#each legal as item (item.href)}
<li><a href={item.href} onclick={closeMenu}>{item.label}</a></li>
+21
View File
@@ -111,9 +111,30 @@ const tabs = [
font-weight: 500;
cursor: pointer;
}
/* The current tab gets a bar along its top edge as well as the accent colour, so colour
is not the only cue (WCAG 1.4.1). It is a pseudo-element, not a border or a filter:
the bar itself must stay a plain opaque strip for Safari 26 (see .tabbar above). */
.tab {
position: relative;
}
.tab[aria-current="page"] {
color: var(--accent);
}
.tab[aria-current="page"]::before {
content: "";
position: absolute;
inset-block-start: 0;
inset-inline: 22%;
block-size: 2px;
border-radius: 0 0 2px 2px;
background: currentColor;
}
/* Forced colours repaint backgrounds; a system colour written here is kept. */
@media (forced-colors: active) {
.tab[aria-current="page"]::before {
background: LinkText;
}
}
.tab-icon {
display: block;
}
+6 -2
View File
@@ -9,8 +9,12 @@ import { formatDate, isoDate } from "../lib/format";
interface Props {
entry: BlogEntry;
locale: Locale;
/** Heading level of the card title: 3 under a section heading, 2 right under the
page's h1 (an index page) — heading levels must not skip. */
headingLevel?: 2 | 3;
}
const { entry, locale } = Astro.props;
const { entry, locale, headingLevel = 3 } = Astro.props;
const Title = `h${headingLevel}` as const;
const t = useTranslations(locale);
const href = sectionPath("blog", locale, entry.id);
const mins = readingTime(entry.body);
@@ -42,7 +46,7 @@ const mins = readingTime(entry.body);
)
}
<div class="card-body">
<h3 class="card-title">{entry.data.title}</h3>
<Title class="card-title">{entry.data.title}</Title>
<p class="card-desc">{entry.data.description}</p>
<div class="card-meta">
<time datetime={isoDate(entry.data.date)}>{formatDate(entry.data.date, locale)}</time>
+4 -2
View File
@@ -9,15 +9,17 @@ interface Props {
emptyText?: string;
emptyHref?: string;
emptyLabel?: string;
/** Passed to every PostCard; see there. */
headingLevel?: 2 | 3;
}
const { posts, locale, emptyText, emptyHref, emptyLabel } = Astro.props;
const { posts, locale, emptyText, emptyHref, emptyLabel, headingLevel } = Astro.props;
---
{
posts.length > 0 ? (
<div class="post-grid">
{posts.map((entry) => (
<PostCard {entry} {locale} />
<PostCard {entry} {locale} {headingLevel} />
))}
</div>
) : (
+6 -2
View File
@@ -6,8 +6,12 @@ import { useTranslations } from "../i18n";
interface Props {
entry: ProjectEntry;
locale: Locale;
/** Heading level of the card title: 3 under a section heading, 2 right under the
page's h1 (an index page) — heading levels must not skip. */
headingLevel?: 2 | 3;
}
const { entry, locale } = Astro.props;
const { entry, locale, headingLevel = 3 } = Astro.props;
const Title = `h${headingLevel}` as const;
const t = useTranslations(locale);
const href = sectionPath("projects", locale, entry.id);
const { name, tagline, stack, repo, url, featured, year } = entry.data;
@@ -16,7 +20,7 @@ const { name, tagline, stack, repo, url, featured, year } = entry.data;
<article class:list={["card project", { featured }]}>
<a class="card-link" href={href}>
<div class="head">
<h3 class="card-title">{name}</h3>
<Title class="card-title">{name}</Title>
<span class="year">{year}</span>
</div>
<p class="tagline">{tagline}</p>
+17
View File
@@ -12,3 +12,20 @@ const { class: className = "", reader = false } = Astro.props;
<div class:list={["prose", { "prose--reader": reader }, className]}>
<slot />
</div>
<script>
// A wide code block scrolls sideways. Chromium and Firefox let the keyboard reach any
// scroller, Safari does not — so a <pre> that overflows joins the tab order (and leaves
// it again once it fits, e.g. after a resize), where arrow keys scroll it (WCAG 2.1.1).
const blocks = document.querySelectorAll<HTMLElement>(".prose pre");
if (blocks.length > 0 && "ResizeObserver" in window) {
const observer = new ResizeObserver((entries) => {
for (const { target } of entries) {
if (!(target instanceof HTMLElement)) continue;
if (target.scrollWidth > target.clientWidth) target.tabIndex = 0;
else target.removeAttribute("tabindex");
}
});
blocks.forEach((pre) => observer.observe(pre));
}
</script>
+23 -1
View File
@@ -19,6 +19,7 @@
let barEl = $state(null);
let panelEl = $state(null);
let aaEl = $state(null);
function target() {
return document.getElementById("reader-root");
@@ -72,7 +73,12 @@
onScroll();
const onKey = (e) => {
if (e.key === "Escape" && open) open = false;
if (e.key !== "Escape" || !open) return;
// The panel is unmounted on close: if focus was inside it, hand it back to the "Aa"
// button rather than letting it fall to <body> (the next Tab would start at the top).
const hadFocus = panelEl?.contains(document.activeElement);
open = false;
if (hadFocus) aaEl?.focus();
};
const onDown = (e) => {
if (open && panelEl && !panelEl.contains(e.target)) open = false;
@@ -95,6 +101,7 @@
<div class="rc" bind:this={panelEl}>
<!-- The name starts with the visible "Aa" so voice control can target it (WCAG 2.5.3). -->
<button
bind:this={aaEl}
type="button"
class="aa"
onclick={() => (open = !open)}
@@ -206,8 +213,23 @@
cursor: pointer;
font-size: var(--text-meta);
}
/* The chosen option is heavier and double-ruled as well as accent-coloured, so colour is
not the only cue (WCAG 1.4.1). The inset shadow thickens the border without moving
the label. */
.opts button.active {
border-color: var(--accent);
color: var(--accent);
font-weight: 700;
box-shadow: inset 0 0 0 1px var(--accent);
}
/* Forced colours drop the shadow and give every button the same border and text colour. */
@media (forced-colors: active) {
.opts button.active {
forced-color-adjust: none;
background: Highlight;
border-color: Highlight;
color: HighlightText;
box-shadow: none;
}
}
</style>
+12
View File
@@ -147,6 +147,7 @@ const strings = {
preview.hidden = true;
}
statusEl.textContent = "";
clearInvalid();
if (REPORT_ENABLED) {
fallback.hidden = true;
submitBtn.hidden = false;
@@ -173,10 +174,21 @@ const strings = {
}
});
const clearInvalid = () => {
desc.removeAttribute("aria-invalid");
desc.removeAttribute("aria-describedby");
};
desc.addEventListener("input", clearInvalid);
submitBtn.addEventListener("click", async () => {
const description = desc.value.trim();
if (description.length < 10) {
// Tie the message to the field and send focus back to it, so a screen reader
// announces what is wrong where it can be fixed (WCAG 3.3.1).
statusEl.textContent = strings.tooShort;
desc.setAttribute("aria-invalid", "true");
desc.setAttribute("aria-describedby", "report-status");
desc.focus();
return;
}
if (!token) {
+18
View File
@@ -77,4 +77,22 @@
background: var(--accent);
translate: 0.775rem -50%;
}
/* Forced colours repaint backgrounds, and the knob is nothing but a background: without
this the switch is an empty outline whose state cannot be seen. System colours written
here are kept. */
@media (forced-colors: active) {
.track {
border-color: ButtonText;
}
.knob {
background: ButtonText;
}
.sb-switch[aria-checked="true"] .track {
background: Highlight;
border-color: Highlight;
}
.sb-switch[aria-checked="true"] .knob {
background: HighlightText;
}
}
</style>
+26 -2
View File
@@ -176,7 +176,12 @@
location.href = flat[selectedIndex].url;
}
} else if (e.key === "Tab") {
const f = dialogEl?.querySelectorAll("input, a[href], button:not(:disabled)");
// Only what Tab can actually reach: the results are options with tabindex="-1"
// (arrow keys move through them). Counting them made the last result the "last"
// stop, which Tab never lands on — so Tab from the Esc button left the dialog.
const f = dialogEl?.querySelectorAll(
'input, a[href]:not([tabindex="-1"]), button:not(:disabled)',
);
if (!f || !f.length) return;
const first = f[0];
const last = f[f.length - 1];
@@ -243,7 +248,10 @@
autocapitalize="off"
spellcheck="false"
/>
<button type="button" class="close" onclick={close} aria-label={labels.close}>Esc</button>
<!-- The name starts with the visible "Esc" so voice control can target it (WCAG 2.5.3). -->
<button type="button" class="close" onclick={close} aria-label={`Esc — ${labels.close}`}
>Esc</button
>
</div>
<div class="results">
@@ -412,6 +420,22 @@
background: var(--surface);
border-inline-start-color: var(--accent);
}
/* Forced colours (Windows High Contrast) drop box-shadows and repaint backgrounds, which
is all the focus indicator and the active option were made of; outlines are kept. The
resting option's transparent edge would turn solid there, so it takes the page colour. */
@media (forced-colors: active) {
.search-row:focus-within {
outline: 2px solid Highlight;
outline-offset: -2px;
}
.result {
border-inline-start-color: Canvas;
}
.result.active {
outline: 2px solid Highlight;
outline-offset: -2px;
}
}
.r-title {
display: block;
font-weight: 600;
+17 -3
View File
@@ -1,5 +1,5 @@
<script>
import { onMount } from "svelte";
import { onMount, tick } from "svelte";
import { externalImagePath } from "../lib/ext-img";
/**
@@ -18,6 +18,17 @@
/** @type {Record<string, boolean>} */
let playing = $state({}); // YouTube facade, per video id: false = thumbnail, true = nocookie iframe
/**
* Swap the thumbnail for the player. The play button is unmounted by that swap, so focus
* moves to the iframe that replaces it instead of falling back to <body>.
* @param {string} id
*/
async function play(id) {
playing[id] = true;
await tick();
document.getElementById(`w-player-${id}`)?.focus();
}
// A source counts as present only when its status is not "na" (and it has items).
const videos = $derived(
data.status?.yt !== "na" ? (data.yt?.items ?? []).slice(0, maxVideos) : [],
@@ -55,6 +66,7 @@
<div class="w-media">
{#if playing[video.id]}
<iframe
id={`w-player-${video.id}`}
title={video.title}
src={`https://www.youtube-nocookie.com/embed/${video.id}?autoplay=1`}
allow="autoplay; encrypted-media; picture-in-picture"
@@ -64,11 +76,13 @@
{#if picture(video.thumb)}
<img src={picture(video.thumb)} alt="" loading="lazy" width="480" height="270" />
{/if}
<!-- The name carries the video's title: the gaming page shows up to three of
these, and three buttons all called "Play video" cannot be told apart. -->
<button
type="button"
class="w-play"
aria-label={labels.playLabel}
onclick={() => (playing[video.id] = true)}
aria-label={`${labels.playLabel}: ${video.title}`}
onclick={() => play(video.id)}
>
▶
</button>
+2 -1
View File
@@ -31,11 +31,12 @@ const tags = collectTags(posts);
}
{
locale === "vi" ? (
<PostGrid {posts} {locale} emptyText="Chưa có bài viết nào." />
<PostGrid {posts} {locale} headingLevel={2} emptyText="Chưa có bài viết nào." />
) : (
<PostGrid
{posts}
{locale}
headingLevel={2}
emptyText={t.post.onlyVi}
emptyHref={sectionPath("blog", "vi")}
emptyLabel="Blog (tiếng Việt)"
+11 -2
View File
@@ -17,14 +17,23 @@ const t = useTranslations(locale);
{/* Tags are per-locale (a vi tag has no guaranteed en page) → no hreflang. */}
<BaseLayout title={`#${tag}`} {locale} alternates={null}>
<section class="page py-section">
<p class="crumb"><a href={sectionPath("blog", locale)}>{t.nav.blog}</a> / #{tag}</p>
<nav class="crumb" aria-label={t.landmarks.breadcrumb}>
<a href={sectionPath("blog", locale)}>{t.nav.blog}</a>
<span aria-hidden="true">/</span>
<span aria-current="page">#{tag}</span>
</nav>
<h1 class="text-h1">#{tag}</h1>
<div class="grid-wrap"><PostGrid {posts} {locale} /></div>
<div class="grid-wrap"><PostGrid {posts} {locale} headingLevel={2} /></div>
</section>
</BaseLayout>
<style>
/* A flex row with a gap: the build strips the whitespace between the link, the slash
and the current page, so the spacing cannot come from the markup. */
.crumb {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
color: var(--muted);
font-family: var(--ff-mono);
font-size: var(--text-meta);
+2 -1
View File
@@ -67,7 +67,8 @@ function relFor(href: string, me?: boolean): string | undefined {
<section class="page block">
<h2 class="block-title">{t.dev.connect}</h2>
<nav class="socials" aria-label={t.footer.social}>
{/* Named after its heading: the footer already has a nav called "Social". */}
<nav class="socials" aria-label={t.dev.connect}>
{
devSocials.map((link) => (
<a
+16 -6
View File
@@ -51,9 +51,11 @@ const slides = await Promise.all(
<BaseLayout title={entry.data.title} description={entry.data.description} {locale}>
<section class="page py-section">
<p class="crumb">
<a href={sectionPath("gallery", locale)}>{t.nav.gallery}</a> / {entry.data.title}
</p>
<nav class="crumb" aria-label={t.landmarks.breadcrumb}>
<a href={sectionPath("gallery", locale)}>{t.nav.gallery}</a>
<span aria-hidden="true">/</span>
<span aria-current="page">{entry.data.title}</span>
</nav>
<h1 class="text-h1">{entry.data.title}</h1>
{entry.data.description && <p class="lead">{entry.data.description}</p>}
<p class="date">{formatDate(entry.data.date, locale)}</p>
@@ -100,7 +102,12 @@ const slides = await Promise.all(
</BaseLayout>
<style>
/* A flex row with a gap: the build strips the whitespace between the link, the slash
and the current page, so the spacing cannot come from the markup. */
.crumb {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
color: var(--muted);
font-family: var(--ff-mono);
font-size: var(--text-meta);
@@ -123,16 +130,19 @@ const slides = await Promise.all(
margin-block-start: 1.5rem;
display: grid;
gap: 0.75rem;
grid-template-columns: repeat(2, 1fr);
/* minmax(0, 1fr), not 1fr: a `1fr` column is at least as wide as its photos' minimum
content size, which made the first column 235px wide and the page wider than a
320px screen. With a zero minimum the columns stay equal. */
grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 640px) {
.photo-grid {
grid-template-columns: repeat(3, 1fr);
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
@media (min-width: 960px) {
.photo-grid {
grid-template-columns: repeat(4, 1fr);
grid-template-columns: repeat(4, minmax(0, 1fr));
}
}
.thumb {
+1 -1
View File
@@ -29,7 +29,7 @@ const cards = await Promise.all(
cards.length > 0 ? (
<div class="gallery-grid">
{cards.map(({ entry, cover }) => (
<GalleryCard {entry} {cover} {locale} />
<GalleryCard {entry} {cover} {locale} headingLevel={2} />
))}
</div>
) : (
+2 -1
View File
@@ -50,7 +50,8 @@ function relFor(href: string, me?: boolean): string | undefined {
<section class="page block">
<h2 class="block-title">{t.gaming.community}</h2>
<nav class="socials" aria-label={t.footer.social}>
{/* Named after its heading: the footer already has a nav called "Social". */}
<nav class="socials" aria-label={t.gaming.community}>
{
gameSocials.map((link) => (
<a
+1
View File
@@ -20,6 +20,7 @@ const titleMap: Record<string, string> = {
"third-party": t.legal.thirdParty,
licenses: t.legal.licenses,
"ai-usage": t.legal.aiUsage,
accessibility: t.legal.accessibility,
};
const title = titleMap[entry.id] ?? entry.data.title;
// Without this every legal page inherited the site-wide default description, so all
+1 -1
View File
@@ -28,7 +28,7 @@ const projects = await getProjects(locale);
projects.length > 0 ? (
<div class="project-grid">
{projects.map((entry) => (
<ProjectCard {entry} {locale} />
<ProjectCard {entry} {locale} headingLevel={2} />
))}
</div>
) : locale === "vi" ? (
+6 -1
View File
@@ -112,6 +112,8 @@ const groups = [
.only-vi a {
color: var(--accent);
font-family: var(--ff-mono);
text-decoration: underline;
text-underline-offset: 0.2em;
}
.qa-group {
margin-block-end: 2rem;
@@ -158,12 +160,15 @@ const groups = [
color: var(--muted);
margin-block: 0.5rem 1rem;
}
/* These links sit inside a sentence, where the accent alone is only 1.6:1 against the
text around it — so they are underlined at rest, not just on hover (WCAG 1.4.1). */
.contact-list a {
color: var(--accent);
text-decoration: underline;
text-underline-offset: 0.2em;
}
.contact-list a:hover {
color: var(--accent-strong);
text-decoration: underline;
}
.contact-list {
list-style: none;
+1
View File
@@ -219,6 +219,7 @@ const en: UIStrings = {
thirdParty: "Third-party",
licenses: "Licenses",
aiUsage: "AI disclosure",
accessibility: "Accessibility",
},
now: {
title: "Now",
+1
View File
@@ -216,6 +216,7 @@ const vi = {
thirdParty: "Bên thứ ba",
licenses: "Giấy phép",
aiUsage: "Sử dụng AI",
accessibility: "Trợ năng",
},
now: {
title: "Bây giờ",
+21 -5
View File
@@ -3,6 +3,7 @@ import BaseLayout from "./BaseLayout.astro";
import Prose from "../components/Prose.astro";
import { useTranslations } from "../i18n";
import { legalNav, isActivePath } from "../lib/nav";
import { markLanguageHalves } from "../lib/legal-lang";
import type { Locale } from "../i18n/routing";
interface Props {
@@ -16,12 +17,18 @@ const t = useTranslations(locale);
const links = legalNav(locale);
const pathname = Astro.url.pathname;
const effectiveLabel = locale === "vi" ? "Hiệu lực" : "Effective";
// The document holds both languages; each half gets its `lang` at build time.
const body = markLanguageHalves(await Astro.slots.render("default"));
---
<BaseLayout {title} {description} {locale}>
<div class="legal-wrap page">
<aside class="legal-side">
<p class="side-title">{t.footer.legal}</p>
{
/* A navigation landmark, named apart from the footer's "Legal" nav so the two can be
told apart in a landmark list. */
}
<nav class="legal-side" aria-label={t.gate.linksLabel}>
<p class="side-title" aria-hidden="true">{t.footer.legal}</p>
<ul>
{
links.map((l) => (
@@ -33,7 +40,7 @@ const effectiveLabel = locale === "vi" ? "Hiệu lực" : "Effective";
))
}
</ul>
</aside>
</nav>
<article class="legal-doc">
<h1>{title}</h1>
@@ -45,15 +52,18 @@ const effectiveLabel = locale === "vi" ? "Hiệu lực" : "Effective";
)
}
<Prose class="legal-body">
<slot />
<Fragment set:html={body} />
</Prose>
</article>
</div>
</BaseLayout>
<style>
/* minmax(0, …): a plain `1fr` column never gets narrower than its longest unbreakable
word, so a bare URL in the text made the whole page 4px wider than a 320px screen. */
.legal-wrap {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 2rem;
padding-block: clamp(2rem, 6vw, 3.5rem);
}
@@ -83,6 +93,12 @@ const effectiveLabel = locale === "vi" ? "Hiệu lực" : "Effective";
.legal-side a[aria-current="page"] {
color: var(--accent);
}
/* Not by colour alone (WCAG 1.4.1). */
.legal-side a[aria-current="page"] {
text-decoration: underline;
text-decoration-thickness: 2px;
text-underline-offset: 0.35em;
}
.legal-doc h1 {
font-size: var(--text-h1);
}
@@ -98,7 +114,7 @@ const effectiveLabel = locale === "vi" ? "Hiệu lực" : "Effective";
@media (min-width: 900px) {
.legal-wrap {
grid-template-columns: 14rem 1fr;
grid-template-columns: 14rem minmax(0, 1fr);
gap: 3rem;
}
.legal-side {
+10 -3
View File
@@ -60,9 +60,11 @@ const crumbs = breadcrumbSchema([
image={ogUrl("project", entry.id)}
>
<article class="proj" data-pagefind-body>
<p class="crumb" data-pagefind-ignore>
<a href={sectionPath("projects", locale)}>{t.nav.projects}</a> / {name}
</p>
<nav class="crumb" aria-label={t.landmarks.breadcrumb} data-pagefind-ignore>
<a href={sectionPath("projects", locale)}>{t.nav.projects}</a>
<span aria-hidden="true">/</span>
<span aria-current="page">{name}</span>
</nav>
<h1>{name}</h1>
<p class="tagline">{tagline}</p>
<div class="facts">
@@ -118,7 +120,12 @@ const crumbs = breadcrumbSchema([
padding-inline: clamp(1rem, 4vw, 2rem);
padding-block: clamp(2rem, 6vw, 3.5rem);
}
/* A flex row with a gap: the build strips the whitespace between the link, the slash
and the current page, so the spacing cannot come from the markup. */
.crumb {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
color: var(--muted);
font-family: var(--ff-mono);
font-size: var(--text-meta);
+19
View File
@@ -130,6 +130,18 @@ const storySchema = {
border-block-end: 1px solid var(--line);
font-size: var(--text-meta);
}
/* The bar is a second sticky strip under the header: tell the page's scroll padding
(global.css) so a control focused by Shift+Tab is not left underneath it. Its height
is the 2.5rem "Aa" button plus the block padding and the border. */
:global(html:has(.reader-bar)) {
--subheader-h: 3.75rem;
}
@media (prefers-reduced-transparency: reduce) {
.reader-bar {
background: var(--bg);
backdrop-filter: none;
}
}
.reader-bar .back {
display: inline-flex;
align-items: center;
@@ -193,6 +205,13 @@ const storySchema = {
--accent-strong: #6f4808;
--accent-contrast: #ffffff;
}
/* global.css strengthens --line under "increase contrast", but the sepia block above is
more specific and would put the faint hairline back. */
@media (prefers-contrast: more) {
.reader[data-reader-theme="sepia"] {
--line: var(--line-strong);
}
}
.reader-head {
margin-block-end: 1.75rem;
text-align: center;
+21
View File
@@ -0,0 +1,21 @@
/**
* Legal documents are bilingual within one file — `## English`, then `## Tiếng Việt` — and
* both locale routes render the whole document. Without a `lang` on the half that is not
* in the page's language, a screen reader reads it with the wrong voice (WCAG 3.1.2).
*
* This wraps each half of the rendered HTML in a container carrying its language. A
* section under any other `<h2>` (the "Models" and "Components" tables) is left alone and
* keeps the page's language. The container is styled `display: contents` (prose.css).
*/
const HALVES: Record<string, string> = { English: "en", "Tiếng Việt": "vi" };
export function markLanguageHalves(html: string): string {
return html
.split(/(?=<h2[\s>])/)
.map((section) => {
const heading = /^<h2[^>]*>([^<]*)<\/h2>/.exec(section)?.[1].trim();
const lang = heading === undefined ? undefined : HALVES[heading];
return lang ? `<div lang="${lang}">${section}</div>` : section;
})
.join("");
}
+1
View File
@@ -44,6 +44,7 @@ export function legalNav(locale: Locale): NavItem[] {
{ href: sectionPath("legal", locale, "third-party"), label: t.legal.thirdParty },
{ href: sectionPath("legal", locale, "licenses"), label: t.legal.licenses },
{ href: sectionPath("legal", locale, "ai-usage"), label: t.legal.aiUsage },
{ href: sectionPath("legal", locale, "accessibility"), label: t.legal.accessibility },
];
}
+32 -3
View File
@@ -130,7 +130,13 @@ html {
/* Height of the sticky site header: the story reader bar docks under it and in-page
anchors stop below it. */
--header-h: 3.75rem;
scroll-padding-block-start: calc(var(--header-h) + 1rem);
/* What covers the bottom edge of the viewport: the fixed mobile tab bar (set below) and,
while it is showing, the legal notice sheet (LegalGateSheet sets --sheet-h). */
--bottom-bar-h: 0px;
scroll-padding-block-start: calc(var(--header-h) + var(--subheader-h, 0px) + 1rem);
/* Focus and in-page anchors scroll clear of those bars instead of landing underneath
them (WCAG 2.4.11 Focus Not Obscured). */
scroll-padding-block-end: calc(max(var(--bottom-bar-h), var(--sheet-h, 0px)) + 1rem);
-webkit-text-size-adjust: 100%;
scrollbar-gutter: stable;
/* Native checkboxes, radios and range inputs take the palette accent. */
@@ -194,10 +200,18 @@ body {
/* Leave room for the fixed mobile tab bar so the footer isn't hidden behind it. */
@media (max-width: 767px) {
body {
padding-block-end: calc(3.5rem + env(safe-area-inset-bottom, 0px));
html {
/* MobileTabBar: 3.5rem of tabs, its 1px top border, and the home-indicator inset. */
--bottom-bar-h: calc(3.5rem + 1px + env(safe-area-inset-bottom, 0px));
}
}
/* …and, at every width, room for the legal notice while it is up. Scroll padding cannot
help at the very end of the document: without this the last links of the footer could
not scroll out from under the sheet (full-width on a phone, a card over the footer's
right half on a tablet). */
body {
padding-block-end: max(var(--bottom-bar-h), var(--sheet-h, 0px));
}
h1,
h2,
@@ -313,6 +327,21 @@ body::after {
}
}
/* ------------------------------------------------------------------ *
* More contrast (the OS "increase contrast" setting): hairlines take the 3:1 line
* colour and the film grain goes away, since it only lowers contrast.
* ------------------------------------------------------------------ */
@media (prefers-contrast: more) {
:root,
[data-theme],
[data-reader-theme] {
--line: var(--line-strong);
}
body::after {
display: none;
}
}
/* Konami easter egg (src/lib/easter.ts): flips the accent to the horror tone for a
beat. Self-reverting after 4s; no layout shift, so reduced-motion needs nothing. */
:root[data-konami="on"] {
+16
View File
@@ -7,6 +7,11 @@
font-size: var(--text-body);
line-height: 1.7;
color: var(--text);
/* A bare URL or an e-mail address is one unbreakable word: on a 320px screen it pushed
the page wider than the viewport. Break inside such words only when nothing else fits.
`break-word`, not `anywhere`: the latter also lets a table shrink its columns below
their longest word, which broke "Anthropic" across two lines in the AI-usage table. */
overflow-wrap: break-word;
}
.prose--reader {
--measure: 68ch;
@@ -17,6 +22,17 @@
.prose > * + * {
margin-block-start: 1em;
}
/* The legal pages wrap each language half in a container that carries `lang`
(src/lib/legal-lang.ts). It takes no box of its own, so the rhythm rule above has to
reach through it; :where() keeps the specificity of that rule, so the heading margins
below still win. */
.prose > [lang] {
display: contents;
}
.prose > :where([lang]) > * + *,
.prose > :where(* + [lang]) > :where(:first-child) {
margin-block-start: 1em;
}
.prose h2,
.prose h3,
.prose h4 {
+476
View File
@@ -0,0 +1,476 @@
// What a static scan cannot see: the things that open (menu, search, photo viewer, report
// dialog, reading settings, legal notice) scanned while open, and the keyboard contract
// around them — Esc closes, focus comes back to what opened it, and focus never lands
// underneath a fixed bar.
import assert from "node:assert/strict";
import { after, before, describe, it } from "node:test";
import type { Browser, BrowserContext, Page } from "playwright";
import {
DESKTOP,
expectNoViolations,
firstMatch,
focused,
launch,
newContext,
open,
PHONE,
settle,
sitemapPaths,
} from "./support.ts";
const paths = await sitemapPaths();
const albumPath = firstMatch(paths, /^\/gallery\/[^/]+\/$/);
const chapterPath = firstMatch(paths, /^\/truyen\/[^/]+\/[^/]+\/$/);
let browser: Browser;
before(async () => {
browser = await launch();
});
after(async () => {
await browser?.close();
});
/** Run `body` in a fresh profile and always close it. */
async function withPage(
options: Parameters<typeof newContext>[1],
path: string,
body: (page: Page, context: BrowserContext) => Promise<void>,
): Promise<void> {
const context = await newContext(browser, options);
try {
await body(await open(context, path), context);
} finally {
await context.close();
}
}
const isInside = (page: Page, selector: string) =>
page.evaluate((sel) => Boolean(document.activeElement?.closest(sel)), selector);
describe("menu sheet (phone)", () => {
it("opens from the tab bar, traps focus, and Esc hands focus back", async () => {
await withPage({ viewport: PHONE }, "/", async (page) => {
const trigger = page.locator(".tabbar [data-menu-trigger]");
await trigger.focus();
await page.keyboard.press("Enter");
await page.waitForSelector("#menu-sheet.open");
assert.equal(await trigger.getAttribute("aria-expanded"), "true");
assert.ok(await isInside(page, "#menu-sheet"), "focus moved into the sheet");
await expectNoViolations(page, "menu sheet open");
for (let i = 0; i < 30; i++) {
await page.keyboard.press("Tab");
assert.ok(await isInside(page, "#menu-sheet"), `Tab #${i + 1} stays in the sheet`);
}
await page.keyboard.press("Escape");
await page.waitForSelector("#menu-sheet:not(.open)");
assert.equal(await trigger.getAttribute("aria-expanded"), "false");
assert.ok(await isInside(page, ".tabbar [data-menu-trigger]"), "focus is back on the button");
});
});
});
describe("search", () => {
it("opens from its button, lists results as options, and Esc hands focus back", async () => {
await withPage({}, "/", async (page) => {
const trigger = page.locator("[data-search-trigger]");
await trigger.focus();
await page.keyboard.press("Enter");
const field = page.locator("#search-modal [role=combobox]");
await field.waitFor();
assert.ok(await isInside(page, "#search-modal [role=combobox]"), "the field has focus");
await field.fill("SkullMute");
await page.waitForSelector("#search-modal [role=option]");
await page.keyboard.press("ArrowDown");
const active = await field.getAttribute("aria-activedescendant");
assert.ok(active, "an option is active");
assert.equal(await page.locator(`#${active}`).getAttribute("aria-selected"), "true");
await expectNoViolations(page, "search open with results");
// The trap has to hold with results listed: they are tabindex="-1" options, and
// counting them once let Tab walk out of the dialog from the Esc button.
for (let i = 0; i < 6; i++) {
await page.keyboard.press("Tab");
assert.ok(await isInside(page, "#search-modal"), `Tab #${i + 1} stays in the search`);
}
for (let i = 0; i < 3; i++) {
await page.keyboard.press("Shift+Tab");
assert.ok(await isInside(page, "#search-modal"), `Shift+Tab #${i + 1} stays in the search`);
}
// WCAG 2.5.3: the close button shows "Esc", so its name has to start with it.
const closeName = await page.locator("#search-modal .close").getAttribute("aria-label");
assert.match(closeName ?? "", /^Esc\b/);
await page.keyboard.press("Escape");
await page.waitForSelector("#search-modal", { state: "detached" });
assert.ok(await isInside(page, "[data-search-trigger]"), "focus is back on the button");
});
});
it('opens with "/" from anywhere on the page', async () => {
await withPage({}, "/", async (page) => {
await page.keyboard.press("/");
await page.waitForSelector("#search-modal [role=combobox]");
assert.ok(await isInside(page, "#search-modal"));
});
});
});
describe("photo viewer", () => {
it("opens from a thumbnail, is scanned open, and Esc returns to the thumbnail", async () => {
await withPage({}, albumPath, async (page) => {
const thumb = page.locator("a.thumb[data-lightbox-index]").first();
await thumb.focus();
await page.keyboard.press("Enter");
await page.waitForSelector(".lb[role=dialog]");
assert.ok(await isInside(page, ".lb"), "focus moved into the viewer");
await expectNoViolations(page, "photo viewer open");
await page.keyboard.press("Escape");
await page.waitForSelector(".lb", { state: "detached" });
assert.ok(
await isInside(page, "a.thumb[data-lightbox-index]"),
"focus is back on a thumbnail",
);
});
});
});
describe("report dialog", () => {
it("is labelled, scanned open, and ties a too-short message to the field", async () => {
await withPage({}, "/", async (page) => {
await page.locator("[data-report-trigger]").first().click();
await page.waitForSelector("dialog#report-dialog[open]");
assert.ok(await isInside(page, "#report-desc"), "the text box has focus");
await expectNoViolations(page, "report dialog open");
// Sending is switched off in builds without a Turnstile site key (CI); the button is
// hidden there and the check has nothing to press.
const submit = page.locator("#report-submit");
if (await submit.isVisible()) {
await submit.click();
const desc = page.locator("#report-desc");
assert.equal(await desc.getAttribute("aria-invalid"), "true");
assert.equal(await desc.getAttribute("aria-describedby"), "report-status");
assert.ok(await isInside(page, "#report-desc"), "focus returns to the field");
await desc.pressSequentially("x");
assert.equal(await desc.getAttribute("aria-invalid"), null);
}
});
});
});
describe("reading settings", () => {
it("is scanned open, and Esc from inside the panel hands focus back to Aa", async () => {
await withPage({}, chapterPath, async (page) => {
const aa = page.locator(".rc .aa");
await aa.focus();
await page.keyboard.press("Enter");
await page.waitForSelector("#reading-controls");
await expectNoViolations(page, "reading settings open");
await page.keyboard.press("Tab");
assert.ok(await isInside(page, "#reading-controls"), "Tab enters the panel");
await page.keyboard.press("Escape");
await page.waitForSelector("#reading-controls", { state: "detached" });
assert.equal(await focused(page), "button.aa");
});
});
});
/**
* Tab (or Shift+Tab) through the page and collect every control that receives focus while
* covered by one of the fixed bars. Stops when focus reaches `until` or after `limit`
* presses. Forward tabbing exercises the bars at the bottom edge, backward the top ones.
*/
async function obscuredWhileTabbing(
page: Page,
bars: string[],
until: string | null,
key: "Tab" | "Shift+Tab" = "Tab",
limit = 250,
) {
const offenders: string[] = [];
for (let i = 0; i < limit; i++) {
await page.keyboard.press(key);
const hit = await page.evaluate(
({ bars, until }) => {
const el = document.activeElement;
if (!el || el === document.body) return { stop: false, offender: null };
if (until && el.closest(until)) return { stop: true, offender: null };
const r = el.getBoundingClientRect();
for (const selector of bars) {
const bar = document.querySelector(selector);
if (!bar || bar.contains(el)) continue;
const b = bar.getBoundingClientRect();
if (b.width === 0 || b.height === 0) continue;
const overlapX = Math.min(r.right, b.right) - Math.max(r.left, b.left);
const overlapY = Math.min(r.bottom, b.bottom) - Math.max(r.top, b.top);
if (overlapX <= 0.5 || overlapY <= 0.5) continue;
// Overlapping is not yet hidden: the skip link is drawn over the header. What
// counts is which of the two is on top where the control's centre is.
const x = Math.min(Math.max(r.left + r.width / 2, 0), window.innerWidth - 1);
const y = Math.min(Math.max(r.top + r.height / 2, 0), window.innerHeight - 1);
const top = document.elementFromPoint(x, y);
if (top && bar.contains(top)) {
const text = (el.textContent ?? "").trim().slice(0, 40);
return {
stop: false,
offender: `${el.tagName.toLowerCase()} "${text}" under ${selector}`,
};
}
}
return { stop: false, offender: null };
},
{ bars, until },
);
if (hit.offender) offenders.push(hit.offender);
if (hit.stop) break;
}
return offenders;
}
describe("focus is not hidden under fixed bars (WCAG 2.4.11)", () => {
it("phone: nothing takes focus underneath the tab bar or the header", async () => {
await withPage({ viewport: PHONE }, "/", async (page) => {
const offenders = await obscuredWhileTabbing(page, [".tabbar", ".site-header"], ".tabbar");
assert.deepEqual(offenders, []);
});
});
it("story reader: nothing takes focus underneath the header or the reader bar going back up", async () => {
await withPage({ viewport: PHONE }, chapterPath, async (page) => {
// Start from the last control of the chapter and walk backwards: only then does the
// browser scroll controls in at the top edge, where the two sticky bars are.
await page.evaluate(() => {
const controls = document.querySelectorAll<HTMLElement>("main a[href], main button");
controls[controls.length - 1]?.focus();
});
assert.ok(await isInside(page, "main"), "the walk starts inside the chapter");
const offenders = await obscuredWhileTabbing(
page,
[".site-header", ".reader-bar"],
".site-header",
"Shift+Tab",
120,
);
assert.deepEqual(offenders, []);
});
});
// The notice is a full-width sheet on a phone and a card in the bottom-right corner from
// 768px up, where on a tablet it lies over the right half of the footer.
for (const [name, viewport] of [
["phone", PHONE],
["tablet", { width: 820, height: 1180 }],
["small laptop", { width: 1024, height: 768 }],
["desktop", DESKTOP],
] as const) {
it(`${name}: the legal notice is scanned, covers nothing that takes focus, and Esc dismisses it`, async () => {
await withPage({ viewport, acknowledged: false }, "/", async (page) => {
await page.waitForSelector("aside.gate", { timeout: 15_000 });
await settle(page);
await expectNoViolations(page, `legal notice showing (${name})`);
if (name === "phone") {
// The notice sits above the tab bar rather than on top of it.
const sheetBottom = await page
.locator("aside.gate")
.evaluate((el) => el.getBoundingClientRect().bottom);
const barTop = await page
.locator(".tabbar")
.evaluate((el) => el.getBoundingClientRect().top);
assert.ok(
sheetBottom <= barTop + 0.5,
`sheet ends at ${sheetBottom}, tab bar starts at ${barTop}`,
);
}
const offenders = await obscuredWhileTabbing(page, ["aside.gate", ".tabbar"], "aside.gate");
assert.deepEqual(offenders, []);
assert.ok(await isInside(page, "aside.gate"), "Tab reaches the notice");
// The height the sheet publishes for the scroll padding has to be right with the
// page scrolled too (Tab has scrolled it by now); a resize makes it measure again.
const [published, covered] = await page.evaluate(() => {
window.dispatchEvent(new Event("resize"));
const gate = document.querySelector("aside.gate");
const top = gate ? gate.getBoundingClientRect().top : window.innerHeight;
const value = getComputedStyle(document.documentElement).getPropertyValue("--sheet-h");
return [Number.parseFloat(value), window.innerHeight - top];
});
assert.ok(
Math.abs(published - covered) <= 1,
`--sheet-h is ${published}px, the sheet covers ${covered}px`,
);
await page.keyboard.press("Escape");
await page.waitForSelector("aside.gate", { state: "detached" });
const cleared = await page.evaluate(() =>
getComputedStyle(document.documentElement).getPropertyValue("--sheet-h"),
);
assert.equal(cleared, "", "--sheet-h is removed with the sheet");
});
});
}
});
describe("page chrome", () => {
it("the first Tab stop is the skip link, and it leads into <main>", async () => {
await withPage({}, "/", async (page) => {
await page.keyboard.press("Tab");
const skip = await page.evaluate(() => {
const el = document.activeElement as HTMLAnchorElement;
const r = el.getBoundingClientRect();
return {
href: el.getAttribute("href"),
visible: r.width > 0 && r.bottom > 0 && r.top >= 0,
};
});
assert.deepEqual(skip, { href: "#main", visible: true });
await page.keyboard.press("Enter");
await page.keyboard.press("Tab");
assert.ok(await isInside(page, "main#main"), "the next Tab stop is inside <main>");
});
});
it("the current page is marked by more than colour (WCAG 1.4.1)", async () => {
await withPage({}, "/blog/", async (page) => {
const decoration = await page
.locator('.primary-nav a[aria-current="page"]')
.evaluate((el) => getComputedStyle(el).textDecorationLine);
assert.match(decoration, /underline/);
});
await withPage({ viewport: PHONE }, "/blog/", async (page) => {
const bar = await page.locator('.tabbar .tab[aria-current="page"]').evaluate((el) => {
const style = getComputedStyle(el, "::before");
return { content: style.content, height: style.height };
});
assert.notEqual(bar.content, "none");
assert.equal(bar.height, "2px");
});
});
it("each half of a legal page declares its own language (WCAG 3.1.2)", async () => {
for (const path of ["/legal/accessibility/", "/en/legal/accessibility/"]) {
await withPage({}, path, async (page) => {
const halves = await page.evaluate(() => {
const en = document.querySelector('[id="english"] + *');
const vi = document.querySelector('[id="tiếng-việt"] + *');
return {
en: en?.matches(":lang(en)") ?? false,
vi: vi?.matches(":lang(vi)") ?? false,
// The wrappers take no box: the paragraph rhythm must survive them.
rhythm: vi ? Number.parseFloat(getComputedStyle(vi).marginBlockStart) : 0,
};
});
assert.deepEqual({ en: halves.en, vi: halves.vi }, { en: true, vi: true }, path);
assert.ok(halves.rhythm > 0, `${path}: paragraphs inside a half keep their spacing`);
});
}
});
it("the home link stays a real target when the wordmark is hidden (WCAG 2.5.8)", async () => {
await withPage({ viewport: { width: 320, height: 640 } }, "/", async (page) => {
const box = await page.locator(".site-header .brand").boundingBox();
assert.ok(box && box.width >= 24 && box.height >= 24, JSON.stringify(box));
});
});
/** Pages wider than the viewport, three loads at a time. */
async function overflowing(width: number, routes: string[]): Promise<string[]> {
const context = await newContext(browser, { viewport: { width, height: 700 } });
const wide: string[] = [];
try {
for (let i = 0; i < routes.length; i += 3) {
await Promise.all(
routes.slice(i, i + 3).map(async (path) => {
const page = await open(context, path);
const overflow = await page.evaluate(
() => document.documentElement.scrollWidth - document.documentElement.clientWidth,
);
await page.close();
if (overflow > 0) wide.push(`${path} (+${overflow}px)`);
}),
);
}
} finally {
await context.close();
}
return wide;
}
// 320px is the WCAG 1.4.10 floor, and every page in the sitemap is held to it.
it("no page scrolls sideways at 320px — every page (WCAG 1.4.10)", async () => {
assert.deepEqual(await overflowing(320, paths), []);
});
// 360 and 390 are the common phone widths, where the header used to be wider than the
// screen (it needs 378px in Vietnamese, 400px in English).
for (const width of [360, 390]) {
it(`no page scrolls sideways at ${width}px (WCAG 1.4.10)`, async () => {
const routes = ["/", "/en/", "/blog/", chapterPath, albumPath, "/en/legal/ai-usage/"];
assert.deepEqual(await overflowing(width, routes), []);
});
}
});
describe("forced colours (Windows High Contrast)", () => {
const forced = { forcedColors: "active" } as const;
const style = (page: Page, selector: string, property: string) =>
page
.locator(selector)
.first()
.evaluate((el, prop) => getComputedStyle(el).getPropertyValue(prop), property);
it("the search field and the active result keep a visible indicator", async () => {
await withPage(forced, "/", async (page) => {
await page.keyboard.press("/");
const field = page.locator("#search-modal [role=combobox]");
await field.waitFor();
assert.equal(await style(page, "#search-modal .search-row", "outline-style"), "solid");
await field.fill("SkullMute");
await page.waitForSelector("#search-modal [role=option]");
await page.keyboard.press("ArrowDown");
assert.equal(await style(page, "#search-modal .result.active", "outline-style"), "solid");
});
});
it("the scrollbar switch shows its knob and its state", async () => {
await withPage(forced, "/", async (page) => {
const button = page.locator(".sb-switch");
await button.scrollIntoViewIfNeeded();
const colours = async () => ({
knob: await style(page, ".sb-switch .knob", "background-color"),
track: await style(page, ".sb-switch .track", "background-color"),
});
const off = await colours();
assert.notEqual(off.knob, off.track, "the knob stands out from the track when off");
await button.click();
assert.equal(await button.getAttribute("aria-checked"), "true");
const on = await colours();
assert.notEqual(on.knob, on.track, "the knob stands out from the track when on");
assert.notEqual(on.track, off.track, "on and off look different");
});
});
it("the chosen reading option is filled, not just recoloured", async () => {
await withPage(forced, chapterPath, async (page) => {
await page.locator(".rc .aa").click();
await page.waitForSelector("#reading-controls");
const chosen = await style(page, "#reading-controls button.active", "background-color");
const other = await style(page, "#reading-controls button:not(.active)", "background-color");
assert.notEqual(chosen, other);
});
});
});
+97
View File
@@ -0,0 +1,97 @@
// axe-core over every page of the build. The list comes from the build's own sitemap, so a
// new page or post is covered the day it exists and a deleted one cannot break the suite.
import { after, before, describe, it } from "node:test";
import type { Browser, BrowserContext } from "playwright";
import {
expectNoViolations,
firstMatch,
launch,
newContext,
open,
PHONE,
sitemapPaths,
} from "./support.ts";
const paths = await sitemapPaths();
// Pages the sitemap leaves out on purpose, which visitors still land on. The two missing
// pages answer 404 with the site's own error page, one per language.
const NOT_FOUND = ["/khong-co-trang-nay/", "/en/no-such-page/"];
const unlisted = [...NOT_FOUND, "/offline/"];
// One page of every template for the second theme and the phone layout: the light palette
// and the narrow layout change colours and chrome, not the structure of every single post.
// A template added later belongs in this list.
const templates = [
"/",
"/en/",
firstMatch(paths, /^\/about\/$/),
firstMatch(paths, /^\/blog\/$/),
firstMatch(paths, /^\/blog\/tag\/[^/]+\/$/),
firstMatch(paths, /^\/blog\/(?!tag\/)[^/]+\/$/),
firstMatch(paths, /^\/truyen\/$/),
firstMatch(paths, /^\/truyen\/[^/]+\/[^/]+\/$/),
firstMatch(paths, /^\/projects\/$/),
firstMatch(paths, /^\/projects\/[^/]+\/$/),
firstMatch(paths, /^\/gallery\/$/),
firstMatch(paths, /^\/gallery\/[^/]+\/$/),
firstMatch(paths, /^\/gaming\/$/),
firstMatch(paths, /^\/dev\/$/),
firstMatch(paths, /^\/dev\/uses\/$/),
firstMatch(paths, /^\/qa\/$/),
firstMatch(paths, /^\/links\/$/),
firstMatch(paths, /^\/now\/$/),
firstMatch(paths, /^\/legal\/accessibility\/$/),
firstMatch(paths, /^\/en\/legal\/accessibility\/$/),
...NOT_FOUND,
];
let browser: Browser;
before(async () => {
browser = await launch();
});
after(async () => {
await browser?.close();
});
function scan(title: string, routes: string[], options: Parameters<typeof newContext>[1]) {
describe(title, { concurrency: 4 }, () => {
let context: BrowserContext;
before(async () => {
context = await newContext(browser, options);
});
after(async () => {
await context?.close();
});
for (const route of routes) {
it(route, async () => {
const page = await open(context, route, NOT_FOUND.includes(route) ? 404 : 200);
try {
await expectNoViolations(page, `${route} (${title})`);
} finally {
await page.close();
}
});
}
});
}
scan("dark theme, desktop — every page", [...paths, ...unlisted], { colorScheme: "dark" });
scan("light theme, desktop — one page per template", templates, { colorScheme: "light" });
scan("dark theme, phone — one page per template", templates, {
colorScheme: "dark",
viewport: PHONE,
});
scan("light theme, phone — one page per template", templates, {
colorScheme: "light",
viewport: PHONE,
});
// Below 384px the header swaps the language name for its code and, below 352px, drops the
// wordmark: scan those two layouts as well.
scan("dark theme, 360px — both home pages", ["/", "/en/"], {
viewport: { width: 360, height: 780 },
});
scan("dark theme, 320px — both home pages", ["/", "/en/"], {
viewport: { width: 320, height: 640 },
});
+144
View File
@@ -0,0 +1,144 @@
// Shared plumbing for the accessibility suite (`npm run test:a11y`).
//
// The suite drives a real browser against a running build — `npm run build`, then
// `npm run preview` on port 4321 (override with A11Y_BASE_URL). It uses the Chrome that is
// already installed (the CI runner ships one), so nothing is downloaded; set A11Y_CHANNEL
// to another Playwright channel ("msedge"), or to "bundled" for Playwright's own Chromium.
import assert from "node:assert/strict";
import { AxeBuilder } from "@axe-core/playwright";
import { chromium, type Browser, type BrowserContext, type Page } from "playwright";
const BASE = (process.env.A11Y_BASE_URL ?? "http://localhost:4321").replace(/\/+$/, "");
/** WCAG 2.2 A + AA (the target in ACCESSIBILITY.md) plus axe's best-practice rules, which
is where heading order and landmark checks live. */
const AXE_TAGS = ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa", "best-practice"];
export const DESKTOP = { width: 1280, height: 800 };
export const PHONE = { width: 390, height: 844 };
export async function launch(): Promise<Browser> {
const channel = process.env.A11Y_CHANNEL ?? "chrome";
return chromium.launch(channel === "bundled" ? {} : { channel });
}
interface ContextOptions {
colorScheme?: "dark" | "light";
viewport?: { width: number; height: number };
forcedColors?: "active" | "none";
/** false = a first-time visitor, who gets the legal notice sheet. */
acknowledged?: boolean;
}
/**
* A fresh browser profile. Reduced motion is on so nothing is caught mid-transition (the
* site collapses every animation under it); the service worker is blocked so each run
* reads the build, not a cache. The site follows the OS colour scheme by default.
*/
export async function newContext(
browser: Browser,
{
colorScheme = "dark",
viewport = DESKTOP,
forcedColors = "none",
acknowledged = true,
}: ContextOptions = {},
): Promise<BrowserContext> {
const context = await browser.newContext({
baseURL: BASE,
colorScheme,
viewport,
forcedColors,
reducedMotion: "reduce",
serviceWorkers: "block",
});
if (acknowledged) {
await context.addInitScript(() => {
try {
localStorage.setItem("legalAck", JSON.stringify({ v: 99, ts: 0 }));
} catch {
/* storage unavailable: the sheet shows, which only makes the scan stricter */
}
});
}
return context;
}
/**
* Load a page and wait until its `client:idle` islands have hydrated. The status is checked
* so that an error page — a 429 from the site-wide rate limit, a route that stopped
* building — is never scanned in the route's place and passed.
*/
export async function open(context: BrowserContext, path: string, status = 200): Promise<Page> {
const page = await context.newPage();
const response = await page.goto(path, { waitUntil: "load" });
assert.equal(response?.status(), status, `${path} answers ${status}`);
await settle(page);
return page;
}
export async function settle(page: Page): Promise<void> {
await page.waitForLoadState("networkidle");
await page.evaluate(
() =>
new Promise<void>((resolve) => {
const done = () => requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
if ("requestIdleCallback" in window) requestIdleCallback(done, { timeout: 2000 });
else setTimeout(done, 200);
}),
);
}
/** Fail with a readable list when axe finds anything on the page as it stands. */
export async function expectNoViolations(page: Page, label: string): Promise<void> {
// The Turnstile widget in the report dialog is Cloudflare's iframe, not this site's
// markup (ACCESSIBILITY.md lists it under known limitations).
const { violations } = await new AxeBuilder({ page })
.withTags(AXE_TAGS)
.exclude("#report-turnstile")
.analyze();
const report = violations
.map((violation) => {
const nodes = violation.nodes
.slice(0, 5)
.map(
(node) =>
` ${node.target.join(" ")}\n ${node.failureSummary?.split("\n").join(" ")}`,
)
.join("\n");
return ` ${violation.id} (${violation.impact}) — ${violation.help}\n${nodes}`;
})
.join("\n");
assert.equal(violations.length, 0, `axe violations on ${label}:\n${report}`);
}
/** Every page of the build, as site-relative paths, read from its own sitemap. */
export async function sitemapPaths(): Promise<string[]> {
const response = await fetch(`${BASE}/sitemap-0.xml`);
assert.equal(response.status, 200, `${BASE}/sitemap-0.xml — is the preview server running?`);
const xml = await response.text();
const paths = [...xml.matchAll(/<loc>([^<]+)<\/loc>/g)].map(
(match) => new URL(match[1]).pathname,
);
assert.ok(paths.length > 10, "the sitemap lists the site's pages");
return [...new Set(paths)].sort();
}
/** The first sitemap path matching a pattern — a stand-in for "one page of this template". */
export function firstMatch(paths: string[], pattern: RegExp): string {
const found = paths.find((path) => pattern.test(path));
assert.ok(found, `a page matching ${pattern} exists in the sitemap`);
return found;
}
/** What has focus, in a form that reads well in an assertion message. */
export async function focused(page: Page): Promise<string> {
return page.evaluate(() => {
const el = document.activeElement;
if (!el || el === document.body) return "body";
const id = el.id ? `#${el.id}` : "";
const cls =
typeof el.className === "string" && el.className ? `.${el.className.split(" ")[0]}` : "";
return `${el.tagName.toLowerCase()}${id}${cls}`;
});
}
+28 -1
View File
@@ -62,6 +62,7 @@ import { toLocale, useTranslations } from "../src/i18n/index.ts";
import vi from "../src/i18n/vi.ts";
import en from "../src/i18n/en.ts";
import { isActivePath, legalNav, menuNav, primaryNav } from "../src/lib/nav.ts";
import { markLanguageHalves } from "../src/lib/legal-lang.ts";
import { DURATION, prefersReducedMotion } from "../src/lib/motion.ts";
import { USES, USES_STACK } from "../src/lib/uses.ts";
@@ -398,6 +399,31 @@ describe("SEO, RSS and OG", () => {
});
});
describe("legal documents", () => {
it("wraps each language half in its lang and leaves other sections alone", () => {
const html =
'<h2 id="english">English</h2><p>One.</p>' +
'<h2 id="tiếng-việt">Tiếng Việt</h2><p>Một.</p><ul><li>Hai</li></ul>' +
'<h2 id="models">Models</h2><table></table>';
assert.equal(
markLanguageHalves(html),
'<div lang="en"><h2 id="english">English</h2><p>One.</p></div>' +
'<div lang="vi"><h2 id="tiếng-việt">Tiếng Việt</h2><p>Một.</p><ul><li>Hai</li></ul></div>' +
'<h2 id="models">Models</h2><table></table>',
);
});
it("keeps whatever precedes the first heading, and a document without halves, as they are", () => {
assert.equal(
markLanguageHalves("<p>Intro.</p><h2>Other</h2><p>x</p>"),
"<p>Intro.</p><h2>Other</h2><p>x</p>",
);
assert.equal(markLanguageHalves(""), "");
// A heading that only mentions a language is not a half.
assert.equal(markLanguageHalves("<h2>English notes</h2>"), "<h2>English notes</h2>");
});
});
describe("i18n and nav", () => {
it("builds localized paths and swaps locales", () => {
assert.equal(homePath("vi"), "/");
@@ -436,7 +462,8 @@ describe("i18n and nav", () => {
it("lists nav items and matches active sections exactly", () => {
assert.equal(primaryNav("en")[0].href, "/en/blog/");
assert.ok(menuNav("vi").some((item) => item.href === "/now/"));
assert.equal(legalNav("en").length, 6);
assert.equal(legalNav("en").length, 7);
assert.equal(legalNav("vi").at(-1)?.href, "/legal/accessibility/");
assert.equal(isActivePath("/blog/post/", "/blog/"), true);
assert.equal(isActivePath("/blogging/", "/blog/"), false);
assert.equal(isActivePath("/en/blog/", "/en/"), false);