#!/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 = `

Gutenberg Storybook

This site needs JavaScript. To read its documentation without a browser, use these sources:

`; const rootElement = '
'; const html = await readFile( indexPath, 'utf8' ); assert( html.includes( '' ), 'Expected a closing head tag' ); assert( html.includes( rootElement ), `Expected ${ rootElement }` ); await writeFile( indexPath, html .replace( '', `${ style }` ) .replace( rootElement, `
${ note }
` ) );