Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ node_modules
.env
_pagefind/
.claude/settings.local.json

# Generated from content/ at build time
/public/llms.txt
/public/llms-full.txt
/public/.ai-docs-manifest.json
/public/**/*.md
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,16 @@ If you have feedback, please open an issue or reach out to [@williamhzo](https:/
## License

All content is © Shape Factory.

## Documentation for AI tools

The production build generates `/llms.txt`, `/llms-full.txt`, and Markdown versions of all documentation pages from `content/` and the shared cards and callouts. Each HTML page links to its Markdown alternative. `/llms.txt` groups entry points by task, while `/llms-full.txt` contains the technical documentation corpus.

```bash
bun run generate:ai-docs
bun run test:ai-docs
```

Edit the MDX source or shared components, then regenerate the assets. Do not edit generated Markdown directly. The converter handles the current static MDX patterns and stops on unknown components, unclosed code fences, or unmapped documentation links. Add conversion support and a test when introducing a new MDX component. Fenced code blocks are preserved verbatim.

Generated files under `public/` are ignored by Git. Both development and production scripts generate them from the existing source before starting Next.js. `.ai-docs-manifest.json` records the generated page paths so deleted pages are removed on regeneration. Each HTML page derives its Markdown alternate from its source file path, which the generator mirrors under `public/`. Titles, summaries, examples, and component text come from the original content; only navigation grouping is configured in the generator.
16 changes: 15 additions & 1 deletion app/[[...mdxPath]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { paths } from '@paths';
import { generateStaticParamsFor, importPage } from 'nextra/pages';
import { useMDXComponents as getMDXComponents } from '../../mdx-components';

Expand All @@ -6,7 +7,20 @@ export const generateStaticParams = generateStaticParamsFor('mdxPath');
export async function generateMetadata(props) {
const params = await props.params;
const { metadata } = await importPage(params.mdxPath);
return metadata;
// Nextra exposes the source file (e.g. content/quick-start/index.mdx); the AI docs
// generator writes its Markdown twin to the same relative path under public/.
const markdown = metadata.filePath?.replace(/^content\//, '/').replace(/\.mdx?$/, '.md');
if (!markdown) return metadata;
return {
...metadata,
alternates: {
...metadata.alternates,
types: {
...metadata.alternates?.types,
'text/markdown': paths.canonical + markdown,
},
},
};
}

const Wrapper = getMDXComponents({}).wrapper;
Expand Down
2 changes: 1 addition & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default async function RootLayout({ children }) {
light: '#fff',
}}
>
{/* Your additional tags should be passed as `children` of `<Head>` element */}
<link rel="describedby" href="/llms.txt" type="text/plain" />
</Head>

<body>
Expand Down
13 changes: 13 additions & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ import type { NextConfig } from 'next';
const withNextra = nextra({});

export default withNextra({
headers: async () => [
...['/llms.txt', '/llms-full.txt'].map((source) => ({
source,
headers: [{ key: 'Content-Type', value: 'text/plain; charset=utf-8' }],
})),
{
source: '/:path*.md',
headers: [
{ key: 'Content-Type', value: 'text/markdown; charset=utf-8' },
{ key: 'Link', value: '</llms.txt>; rel="describedby"' },
],
},
],
redirects: () => [
{
source: '/building-on-shape/gasback',
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"scripts": {
"dev": "next dev",
"build": "next build",
"dev": "node scripts/generate-ai-docs.mjs && next dev",
"build": "node scripts/generate-ai-docs.mjs && next build",
"start": "next start",
"postbuild": "pagefind --site .next/server/app --output-path public/_pagefind"
"postbuild": "pagefind --site .next/server/app --output-path public/_pagefind",
"generate:ai-docs": "node scripts/generate-ai-docs.mjs",
"test:ai-docs": "SHAPE_DOCS_TEST_ROOT=. node --test scripts/generate-ai-docs.test.mjs"
},
"dependencies": {
"@tailwindcss/postcss": "^4.1.18",
Expand Down
70 changes: 0 additions & 70 deletions public/llms.txt

This file was deleted.

Loading