Repository navigation
Storybook: Add a note for agents that read the page without JavaScript - #85757
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: 0 B Total Size: 8.56 MB
|
|
@aduth I tried to see if I could test the efficacy of this strategy locally, but the several sets of tests I could run were inconclusive, mainly because:
So I think we might have to test after deploy, and tweak or revert if there's no measurable difference. Worth trying? |
|
I think it's worth testing! I had actually explored something nearly identical in the past, and came to a few related conclusions / observations:
The only remaining concerns I had / have are:
|
| const rawBaseUrl = | ||
| 'https://raw.githubusercontent.com/WordPress/gutenberg/trunk'; |
There was a problem hiding this comment.
Do we have a constant we can use instead? I suppose this likely won't change though so maybe not worth dwelling on.
| const style = '<style>#agent-docs-note { display: none; }</style>'; | ||
|
|
||
| const note = `<div id="agent-docs-note"> |
There was a problem hiding this comment.
Could this be an inline style?
| const style = '<style>#agent-docs-note { display: none; }</style>'; | |
| const note = `<div id="agent-docs-note"> | |
| const note = `<div style="display: none"> |
There was a problem hiding this comment.
I tried the inline style, but Mozilla Readability skips elements with an inline display: none, so the note disappeared from its output. A <style> rule in <head> hides it before the first paint just as well, and all six HTML-to-text tools I tested kept the note with it. I added a comment explaining this.
Trying to track this down, it was a local-only exploration I had, and it falls outside my Claude default retention window. I managed to salvage some metadata (my own prompting) to piece together some additional context, some of which mentioned already:
|
|
Thanks, this matches what I saw. On flash: the note is hidden by a stylesheet in I compared six HTML-to-text tools (Turndown, node-html-markdown, html-to-text, Readability, html2text, markdownify). Agreed on I also ran fresh agents in an empty project with only the lint message. Haiku opened the |
Right, I think we're covered. Storybook's manager template only has a |
|
Couple related links for posterity:
|
What?
Follow up to #85752 (comment).
Add a note to the Storybook page that tells AI agents and other tools without JavaScript where to read the documentation.
Why?
Storybook links, such as those in
use-recommended-componentslint messages, are not useful to AI agents. Fetchinghttps://wordpress.github.io/gutenberg/?path=/docs/components-checkboxcontrol--migration-guidewithout JavaScript returns only the page title "storybook - Storybook". The documentation is available in machine-readable form, but nothing on the page says where.How?
A post-build script adds the note inside the manager's root element in
index.html. The note points to the Design System MCP server, toindex.jsonand how to map a page'spathparameter to its source file on GitHub, and tomanifests/components.json.The note is hidden with CSS, and the manager replaces it when it renders, so the page looks the same in a browser. Tools that convert HTML to text do not apply stylesheets, so they still read it. I put the note in the root element instead of
<noscript>because some of these tools skip<noscript>content. Turndown, node-html-markdown, html-to-text, Readability, html2text, and markdownify all include the note in their output.Testing Instructions
npm run storybook:build.storybook/build/index.htmlcontains the note inside<div id="root">.storybook/buildand open it in a browser. Confirm that Storybook loads as before and that the note is not visible, including while the page loads.