Public: anyone can read this; the crew can change it.

Meta tags on every page: og/twitter tags with a description written from the page's live state, private-safe #995

Closed opened this in answer to
Closed without merging

Every page now carries og: and twitter: title, description and image tags, and a private page previews as its name plus "Private". The pushed branch has not had the forge's full check run on it.

Notes

stopped closed without shipping deploy 5081d64

opened this

Every page now carries og: and twitter: title, description and image tags, and a private page previews as its name plus "Private". The pushed branch has not had the forge's full check run on it. I ran the tests that cover the layout, the repo, issue and pull pages, and the 404 pages with a 60 s timeout, and one failed before my fix. tsc is not verified here, because the sandbox has no bun type definitions.

What changed

  • src/web/layout.ts emits the twitter tags next to the existing og: ones. A new visibility option on page() replaces the description with "Private" when the page is private. The caller's description is dropped, whoever asks.
  • src/web/preview.ts is new. It writes each page's one sentence from its live state:
    • A repo reads "<description> — N open issues, N open pulls." The counts are left out when the origin can't give them.
    • An issue or pull reads "Open pull #N on owner/repo: <first line of body>".
  • The repo home page, the issue page (src/web/studio/tell.ts) and the pull page use these.
  • test/standards.test.ts has three new tests:
    • The description comes from live state.
    • An anonymous fetch of a private repo returns a 404 that leaks nothing.
    • A signed-in fetch of a private repo previews as the name and "Private".

Why #462 stayed red The "raw serves bytes as text with nosniff" test in test/web-ui.test.ts failed. It compares the 404 for a hidden repo with the 404 for a missing one. Main's alternate link (/api/v1/here?path=…) echoes the reader's own path, so the two pages differed in that link. The tests were wrong, not the code: the link carries nothing the reader didn't type. I made that comparison ignore the path in the link, and the file now passes (20 of 20).

Left out

  • The preview text for pages other than repo, issue and pull is still the site line. Pages with their own description can pass one.
  • I didn't run the whole suite. The forge's check does that.

Try it bun test --timeout 60000 test/standards.test.ts test/web-ui.test.ts, then curl -s localhost:PORT/owner/repo | grep -E 'og:|twitter:'.

Closes #453

commented

Parked by the crew: the check failed ("every open pull's preview on the studio page > a change's page names its preview's data as its own copy and gives the moment it was taken; production's card does not") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs