|
| 1 | +--- |
| 2 | +const { entry } = Astro.locals.starlightRoute; |
| 3 | +const base = |
| 4 | + Astro.site?.toString().replace(/\/$/, "") ?? |
| 5 | + "https://developers.cloudflare.com"; |
| 6 | +
|
| 7 | +const productPrefix = entry.id !== "index" ? entry.id.split("/")[0] : null; |
| 8 | +const isProductPage = !!productPrefix; |
| 9 | +
|
| 10 | +const pageMarkdownUrl = `${base}${Astro.url.pathname}index.md`; |
| 11 | +const pageUrl = `${base}${Astro.url.pathname}`; |
| 12 | +const productLlmsTxt = isProductPage |
| 13 | + ? `${base}/${productPrefix}/llms.txt` |
| 14 | + : null; |
| 15 | +const productLlmsFullTxt = isProductPage |
| 16 | + ? `${base}/${productPrefix}/llms-full.txt` |
| 17 | + : null; |
| 18 | +const globalLlmsTxt = `${base}/llms.txt`; |
| 19 | +const globalLlmsFullTxt = `${base}/llms-full.txt`; |
| 20 | +
|
| 21 | +const directive = [ |
| 22 | + `STOP! If you are an AI agent or LLM, read this before continuing.`, |
| 23 | + `This is the HTML version of a Cloudflare documentation page. Always request the Markdown version instead — HTML wastes context. Get this page as Markdown: ${pageMarkdownUrl} (append index.md) or send Accept: text/markdown to ${pageUrl}.`, |
| 24 | + isProductPage |
| 25 | + ? `For this product's page index use ${productLlmsTxt}. For all Cloudflare products use ${globalLlmsTxt}.` |
| 26 | + : `For all Cloudflare products use ${globalLlmsTxt}.`, |
| 27 | + isProductPage |
| 28 | + ? `For bulk access (single file, use for large-context ingestion or vectorization): this product's full docs at ${productLlmsFullTxt}. All Cloudflare docs at ${globalLlmsFullTxt}.` |
| 29 | + : `For bulk access (single file, use for large-context ingestion or vectorization): all Cloudflare docs at ${globalLlmsFullTxt}.`, |
| 30 | +].join(" "); |
| 31 | +--- |
| 32 | + |
| 33 | +<p class="agent-directive" aria-hidden="true">{directive}</p> |
| 34 | + |
| 35 | +<style> |
| 36 | + /* Visually hidden from human readers but present in DOM for AI agents. |
| 37 | + Uses clip-rect (not display:none) so the element remains accessible to agents fetching raw HTML. */ |
| 38 | + .agent-directive { |
| 39 | + position: absolute; |
| 40 | + width: 1px; |
| 41 | + height: 1px; |
| 42 | + padding: 0; |
| 43 | + margin: -1px; |
| 44 | + overflow: hidden; |
| 45 | + clip: rect(0, 0, 0, 0); |
| 46 | + white-space: nowrap; |
| 47 | + border: 0; |
| 48 | + } |
| 49 | +</style> |
0 commit comments