diff --git a/astro.config.ts b/astro.config.ts index 1dcc9921a566b..81a12b89e8317 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -7,6 +7,7 @@ import { sidebar } from './astro.sidebar'; import { devServerFileWatcher } from './config/integrations/dev-server-file-watcher'; import { sitemap } from './config/integrations/sitemap'; import { makeLocalesConfig } from './config/locales'; +import { starlightPluginLlmsTxt } from './config/plugins/llms-txt'; import { starlightPluginAutolinkHeadings } from './config/plugins/rehype-autolink'; import { rehypeTasklistEnhancer } from './config/plugins/rehype-tasklist-enhancer'; import { remarkFallbackLang } from './config/plugins/remark-fallback-lang'; @@ -21,7 +22,7 @@ export default defineConfig({ site, integrations: [ devServerFileWatcher([ - './config/*', // Custom plugins and integrations + './config/**', // Custom plugins and integrations './astro.sidebar.ts', // Sidebar configuration file './src/content/nav/*.ts', // Sidebar labels ]), @@ -69,7 +70,7 @@ export default defineConfig({ }, ], disable404Route: true, - plugins: [starlightPluginAutolinkHeadings()], + plugins: [starlightPluginAutolinkHeadings(), starlightPluginLlmsTxt()], }), sitemap(), ], diff --git a/config/plugins/llms-txt.ts b/config/plugins/llms-txt.ts new file mode 100644 index 0000000000000..7332af57bc1cf --- /dev/null +++ b/config/plugins/llms-txt.ts @@ -0,0 +1,116 @@ +import starlightLlmsTxt from 'starlight-llms-txt'; + +/** Starlight plugin that sets up `starlight-llms-txt` with configuration for the Astro docs. */ +export const starlightPluginLlmsTxt = () => + starlightLlmsTxt({ + // Basic information about the docs and Astro to display in the main `llms.txt` entry file. + projectName: 'Astro', + description: 'Astro is an all-in-one web framework for building websites. ', + details: [ + '- Astro uses island architecture and server-first design to reduce client-side JavaScript overhead and ship high performance websites.', + '- Astro’s friendly content-focused features like content collections and built-in Markdown support make it an excellent choice for blogs, marketing, and e-commerce sites amongst others.', + '- The `.astro` templating syntax provides powerful server rendering in a format that follows HTML standards and will feel very familiar to anyone who has used JSX.', + '- Astro supports popular UI frameworks like React, Vue, Svelte, Preact, and Solid through official integrations.', + '- Astro is powered by Vite, comes with a fast development server, bundles your JavaScript and CSS for you, and makes building websites feel fun.', + ].join('\n'), + optionalLinks: [ + { + label: 'The Astro blog', + url: 'https://astro.build/blog/', + description: 'the latest news about Astro development', + }, + ], + + // Create custom subsets of docs to break things up. + customSets: [ + { + label: 'API Reference', + description: 'terse, structured descriptions of Astro’s APIs', + paths: ['en/reference/**', 'en/guides/imports'], + }, + { + label: 'How-to Recipes', + description: 'guided examples of adding features to an Astro project', + paths: ['en/recipes/**'], + }, + { + label: 'Build a Blog Tutorial', + description: 'a step-by-step guide to building a basic blog with Astro', + paths: ['en/tutorial/**'], + }, + { + label: 'Deployment Guides', + description: 'recipes for how to deploy an Astro website to different services', + paths: ['en/guides/deploy/**'], + }, + { + label: 'CMS Guides', + description: + 'recipes for how to use different content management systems in an Astro project', + paths: ['en/guides/cms/**'], + }, + { + label: 'Backend Services', + description: + 'advice on how to integrate backend services like Firebase, Sentry, and Supabase in an Astro project', + paths: ['en/guides/migrate-to-astro/**'], + }, + { + label: 'Migration Guides', + description: 'advice on how to migrate a project built with another tool to Astro', + paths: ['en/guides/migrate-to-astro/**'], + }, + { + label: 'Additional Guides', + description: + 'guides to e-commerce, authentication, testing, and digital asset management in Astro projects', + paths: [ + 'en/guides/ecommerce', + 'en/guides/authentication', + 'en/guides/testing', + 'en/guides/media/**', + ], + }, + ], + + // Control the order of pages in output files. + promote: [ + 'en/concepts/why-astro', + 'en/concepts/islands', + 'en/install-and-setup', + 'en/basics/project-structure', + 'en/develop-and-build', + 'en/guides/configuring-astro', + ], + + // Exclude pages from the abridged `llms-small.txt` file designed for smaller context windows. + exclude: [ + // Landing page doesn’t really include any helpful content on its own, so it is excluded. + 'en/getting-started', + // We can exclude this from the abridged docs as nonessential. + 'en/contribute', + // Legacy flags and old upgrade guides also seem reasonable to exclude from the abridged docs. + 'en/reference/legacy-flags', + 'en/guides/upgrade-to/v{1..4}', + + // The following are all excluded because they are split out using `customSets`. + + // How-to Recipes + 'en/recipes/**', + // Build a Blog Tutorial + 'en/tutorial/**', + // API Reference + 'en/reference/**', + 'en/guides/imports', + // Each of these categories is included in a dedicated custom set. + 'en/guides/backend/**', + 'en/guides/cms/**', + 'en/guides/deploy/**', + 'en/guides/migrate-to-astro/**', + // Additional Guides + 'en/guides/ecommerce', + 'en/guides/authentication', + 'en/guides/testing', + 'en/guides/media/**', + ], + }); diff --git a/package.json b/package.json index 019990c8d2927..5d02dfeccec3e 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,8 @@ "rehype-slug": "^6.0.0", "remark-gfm": "^4.0.1", "remark-smartypants": "^2.0.0", - "sharp": "^0.33.5" + "sharp": "^0.33.5", + "starlight-llms-txt": "^0.5.1" }, "packageManager": "pnpm@9.15.1", "pnpm": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 09eb99ea69e34..fec528f5ae1c0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,9 @@ importers: sharp: specifier: ^0.33.5 version: 0.33.5 + starlight-llms-txt: + specifier: ^0.5.1 + version: 0.5.1(@astrojs/starlight@0.31.1(astro@5.5.3(@types/node@20.17.10)(jiti@2.3.3)(rollup@4.34.9)(sass@1.54.3)(typescript@5.6.2)(yaml@2.5.1)))(astro@5.5.3(@types/node@20.17.10)(jiti@2.3.3)(rollup@4.34.9)(sass@1.54.3)(typescript@5.6.2)(yaml@2.5.1)) devDependencies: '@11ty/eleventy-fetch': specifier: ^5.0.1 @@ -944,6 +947,9 @@ packages: '@types/acorn@4.0.6': resolution: {integrity: sha512-veQTnWP+1D/xbxVrPC3zHnCZRjSrKfhbMUlEA43iMZLu7EsnTtkJklIuwrCPbOi8YkvDQAiW05VQQFvvz9oieQ==} + '@types/braces@3.0.5': + resolution: {integrity: sha512-SQFof9H+LXeWNz8wDe7oN5zu7ket0qwMu5vZubW4GCJ8Kkeh6nBWUz87+KTz/G3Kqsrp0j/W253XJb3KMEeg3w==} + '@types/canvas-confetti@1.6.0': resolution: {integrity: sha512-Yq6rIccwcco0TLD5SMUrIM7Fk7Fe/C0jmNRxJJCLtAF6gebDkPuUjK5EHedxecm69Pi/aA+It39Ux4OHmFhjRw==} @@ -986,6 +992,9 @@ packages: '@types/mdx@2.0.5': resolution: {integrity: sha512-76CqzuD6Q7LC+AtbPqrvD9AqsN0k8bsYo2bM2J8pmNldP1aIPAbzUQ7QbobyXL4eLr1wK5x8FZFe8eF/ubRuBg==} + '@types/micromatch@4.0.9': + resolution: {integrity: sha512-7V+8ncr22h4UoYRLnLXSpTxjQrNUXtWHGeMPRJt1nULXI57G9bIcpyrHlmrQ7QK24EyyuXvYcSSWAM8GA9nqCg==} + '@types/ms@0.7.31': resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==} @@ -1856,6 +1865,9 @@ packages: hast-util-to-jsx-runtime@2.3.0: resolution: {integrity: sha512-H/y0+IWPdsLLS738P8tDnrQ8Z+dj12zQQ6WC11TIM21C8WFVoIxcqWXf2H3hiTVZjF1AWqoimGwrTWecWrnmRQ==} + hast-util-to-mdast@10.1.2: + resolution: {integrity: sha512-FiCRI7NmOvM4y+f5w32jPRzcxDIz+PUqDwEqn1A+1q2cdp3B8Gx7aVrXORdOKjMNDQsD1ogOr896+0jJHW1EFQ==} + hast-util-to-parse5@8.0.0: resolution: {integrity: sha512-3KKrV5ZVI8if87DVSi1vDeByYrkGzg4mEfeu4alwgmmIeARiBLKCZS2uw5Gb6nU9x9Yufyj3iudm6i7nl52PFw==} @@ -2547,8 +2559,8 @@ packages: rehype-minify-whitespace@6.0.0: resolution: {integrity: sha512-i9It4YHR0Sf3GsnlR5jFUKXRr9oayvEk9GKQUkwZv6hs70OH9q3OCZrq9PpLvIGKt3W+JxBOxCidNVpH/6rWdA==} - rehype-parse@9.0.0: - resolution: {integrity: sha512-WG7nfvmWWkCR++KEkZevZb/uw41E8TsH4DsY9UxsTbIXCVGbAs4S+r8FrQ+OtH5EEQAs+5UxKC42VinkmpA1Yw==} + rehype-parse@9.0.1: + resolution: {integrity: sha512-ksCzCD0Fgfh7trPDxr2rSylbwq9iYDkSn8TCDmEJ49ljEUBxDVCzCHv7QNzZOfODanX4+bWQ4WZqLCRWYLfhag==} rehype-raw@7.0.0: resolution: {integrity: sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==} @@ -2556,6 +2568,9 @@ packages: rehype-recma@1.0.0: resolution: {integrity: sha512-lqA4rGUf1JmacCNWWZx0Wv1dHqMwxzsDWYMTowuplHF3xH0N/MmrZ/G3BDZnzAkRmxDadujCjaKM2hqYdCBOGw==} + rehype-remark@10.0.0: + resolution: {integrity: sha512-+aDXY/icqMFOafJQomVjxe3BAP7aR3lIsQ3GV6VIwpbCD2nvNFOXjGvotMe5p0Ny+Gt6L13DhEf/FjOOpTuUbQ==} + rehype-slug@6.0.0: resolution: {integrity: sha512-lWyvf/jwu+oS5+hL5eClVd3hNdmwM1kAC0BUvEGD19pajQMIzcNUd/k9GsfQ+FfECvX+JE+e9/btsKH0EjJT6A==} @@ -2721,6 +2736,13 @@ packages: space-separated-tokens@2.0.2: resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==} + starlight-llms-txt@0.5.1: + resolution: {integrity: sha512-EPhTZ7jOhMxp6BBSpYNWuaJezzI+4eRgkwlFGV/XNNGSjNibo9JHrCvCbJO6BDk4znXcTWi0x8N7FO7ckNXLGQ==} + engines: {node: ^18.17.1 || ^20.3.0 || >=21.0.0} + peerDependencies: + '@astrojs/starlight': '>=0.31' + astro: ^5.1.6 + stream-replace-string@2.0.0: resolution: {integrity: sha512-TlnjJ1C0QrmxRNrON00JvaFFlNh5TTG00APw23j74ET7gkQpTASi6/L2fuiav8pzK715HXtUeClpBTw2NPSn6w==} @@ -2778,6 +2800,9 @@ packages: trim-lines@3.0.1: resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==} + trim-trailing-lines@2.1.0: + resolution: {integrity: sha512-5UR5Biq4VlVOtzqkm2AZlgvSlDJtME46uV0br0gENbwN4l5+mMKT4b9gJKqWtuL2zAIqajGJGuvbCbcAJUZqBg==} + trough@2.1.0: resolution: {integrity: sha512-AqTiAOLcj85xS7vQ8QkAV41hPDIJ71XJB4RCUrzo/1GM2CQwhkJGaf9Hgr7BOugMRpgGUrqRg/DrBDl4H40+8g==} @@ -2889,6 +2914,9 @@ packages: unist-util-remove-position@5.0.0: resolution: {integrity: sha512-Hp5Kh3wLxv0PHj9m2yZhhLt58KzPtEYKQQ4yxfYFEO7EvHwzyDYnduhHnY1mDxoqr7VUwVuHXk9RXKIiYS1N8Q==} + unist-util-remove@4.0.0: + resolution: {integrity: sha512-b4gokeGId57UVRX/eVKej5gXqGlc9+trkORhFJpu9raqZkZhU0zm8Doi05+HaiBsMEIJowL+2WtQ5ItjsngPXg==} + unist-util-stringify-position@3.0.3: resolution: {integrity: sha512-k5GzIBZ/QatR8N5X2y+drfpWG8IDBzdnVj6OInRNWm1oXrzydiaAT2OQiA8DPRRZyAKb9b6I2a6PxYklZD0gKg==} @@ -4107,6 +4135,8 @@ snapshots: dependencies: '@types/estree': 1.0.6 + '@types/braces@3.0.5': {} + '@types/canvas-confetti@1.6.0': {} '@types/cookie@0.6.0': {} @@ -4146,6 +4176,10 @@ snapshots: '@types/mdx@2.0.5': {} + '@types/micromatch@4.0.9': + dependencies: + '@types/braces': 3.0.5 + '@types/ms@0.7.31': {} '@types/nlcst@1.0.4': @@ -5260,6 +5294,23 @@ snapshots: transitivePeerDependencies: - supports-color + hast-util-to-mdast@10.1.2: + dependencies: + '@types/hast': 3.0.4 + '@types/mdast': 4.0.4 + '@ungap/structured-clone': 1.2.0 + hast-util-phrasing: 3.0.1 + hast-util-to-html: 9.0.5 + hast-util-to-text: 4.0.2 + hast-util-whitespace: 3.0.0 + mdast-util-phrasing: 4.0.0 + mdast-util-to-hast: 13.0.2 + mdast-util-to-string: 4.0.0 + rehype-minify-whitespace: 6.0.0 + trim-trailing-lines: 2.1.0 + unist-util-position: 5.0.0 + unist-util-visit: 5.0.0 + hast-util-to-parse5@8.0.0: dependencies: '@types/hast': 3.0.4 @@ -6282,7 +6333,7 @@ snapshots: hast-util-whitespace: 3.0.0 unist-util-is: 6.0.0 - rehype-parse@9.0.0: + rehype-parse@9.0.1: dependencies: '@types/hast': 3.0.4 hast-util-from-html: 2.0.3 @@ -6302,6 +6353,14 @@ snapshots: transitivePeerDependencies: - supports-color + rehype-remark@10.0.0: + dependencies: + '@types/hast': 3.0.4 + '@types/mdast': 4.0.4 + hast-util-to-mdast: 10.1.2 + unified: 11.0.5 + vfile: 6.0.3 + rehype-slug@6.0.0: dependencies: '@types/hast': 3.0.4 @@ -6319,7 +6378,7 @@ snapshots: rehype@13.0.2: dependencies: '@types/hast': 3.0.4 - rehype-parse: 9.0.0 + rehype-parse: 9.0.1 rehype-stringify: 10.0.1 unified: 11.0.5 @@ -6587,6 +6646,25 @@ snapshots: space-separated-tokens@2.0.2: {} + starlight-llms-txt@0.5.1(@astrojs/starlight@0.31.1(astro@5.5.3(@types/node@20.17.10)(jiti@2.3.3)(rollup@4.34.9)(sass@1.54.3)(typescript@5.6.2)(yaml@2.5.1)))(astro@5.5.3(@types/node@20.17.10)(jiti@2.3.3)(rollup@4.34.9)(sass@1.54.3)(typescript@5.6.2)(yaml@2.5.1)): + dependencies: + '@astrojs/mdx': 4.0.8(astro@5.5.3(@types/node@20.17.10)(jiti@2.3.3)(rollup@4.34.9)(sass@1.54.3)(typescript@5.6.2)(yaml@2.5.1)) + '@astrojs/starlight': 0.31.1(astro@5.5.3(@types/node@20.17.10)(jiti@2.3.3)(rollup@4.34.9)(sass@1.54.3)(typescript@5.6.2)(yaml@2.5.1)) + '@types/hast': 3.0.4 + '@types/micromatch': 4.0.9 + astro: 5.5.3(@types/node@20.17.10)(jiti@2.3.3)(rollup@4.34.9)(sass@1.54.3)(typescript@5.6.2)(yaml@2.5.1) + github-slugger: 2.0.0 + hast-util-select: 6.0.3 + micromatch: 4.0.8 + rehype-parse: 9.0.1 + rehype-remark: 10.0.0 + remark-gfm: 4.0.1 + remark-stringify: 11.0.0 + unified: 11.0.5 + unist-util-remove: 4.0.0 + transitivePeerDependencies: + - supports-color + stream-replace-string@2.0.0: {} string-width@4.2.3: @@ -6650,6 +6728,8 @@ snapshots: trim-lines@3.0.1: {} + trim-trailing-lines@2.1.0: {} + trough@2.1.0: {} ts-api-utils@2.0.0(typescript@5.6.2): @@ -6764,6 +6844,12 @@ snapshots: '@types/unist': 3.0.2 unist-util-visit: 5.0.0 + unist-util-remove@4.0.0: + dependencies: + '@types/unist': 3.0.2 + unist-util-is: 6.0.0 + unist-util-visit-parents: 6.0.1 + unist-util-stringify-position@3.0.3: dependencies: '@types/unist': 2.0.8