#!/usr/bin/env node /** * Adds a note for AI agents and other tools that read the Storybook page * without running JavaScript, which otherwise see only the page title. * * The note sits inside the manager's root element, so the manager replaces it * when it renders. It is hidden with CSS, since tools that convert HTML to text * do not apply stylesheets and some skip `noscript` content. */ import { readFile, writeFile } from 'node:fs/promises'; import assert from 'node:assert'; const indexPath = process.argv[ 2 ]; assert( indexPath, 'Storybook index.html path is required' ); const rawBaseUrl = 'https://raw.githubusercontent.com/WordPress/gutenberg/trunk'; // Not an inline style, since Mozilla Readability, which some tools use to // extract page text, skips elements with an inline `display: none`. const style = ''; const note = `
This site needs JavaScript. To read its documentation without a browser, use these sources:
path parameter of a page URL, such as ?path=/docs/components-checkboxcontrol--migration-guide, ends with the ID of its entry. The entry's importPath is the source file, relative to the storybook directory of the Gutenberg repository. For example, that page's source is ${ rawBaseUrl }/packages/components/src/checkbox-control/stories/migration-guide.mdx.