-
Notifications
You must be signed in to change notification settings - Fork 95
Add /llms.txt endpoints for LLM-consumable documentation #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e0d653f
Initial plan
Copilot a4bd894
Implement /llms.txt and /llms-full.txt endpoints
Copilot 77ef430
Fix JSX tag removal to handle nested components properly
Copilot fad20a3
Replace regex with remark plugin for JSX stripping
Copilot eb20312
Replace JSX components with textual placeholders without children
Copilot 85316e5
Only replace React components (uppercase), preserve HTML tags
Copilot def4a47
Remove JSX stripping - keep all tags as-is
Copilot 9b42c41
Add .md routes for raw source files with llms.txt compatible frontmatter
Copilot c801b2e
Add .md routes to serve raw MDX source files
Copilot ff62967
Fix TypeScript error in .md route handler params
Copilot 1765dd6
Co-authored-by: abernier <[email protected]>
Copilot 182d11d
Fix TypeScript build error - use Record type for params
Copilot c98943d
.
abernier 537fef9
link
abernier 395a16e
agents
abernier 7733862
docs(changeset): llms.txt
abernier d408942
Remove unused remark dependencies
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@pmndrs/docs': minor | ||
| --- | ||
|
|
||
| llms.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { parseDocsMetadata } from '@/utils/docs' | ||
|
|
||
| export const dynamic = 'force-static' | ||
|
|
||
| /** | ||
| * Basic cleanup of markdown content | ||
| */ | ||
| function cleanMarkdown(content: string): string { | ||
| // Just do basic cleanup - keep JSX tags as-is | ||
| return content | ||
| .replace(/\n{3,}/g, '\n\n') // Clean up multiple empty lines | ||
| .trim() | ||
| } | ||
|
|
||
| export async function GET() { | ||
| const { MDX, NEXT_PUBLIC_LIBNAME, NEXT_PUBLIC_URL } = process.env | ||
| if (!MDX) throw new Error('MDX env var not set') | ||
| if (!NEXT_PUBLIC_LIBNAME) throw new Error('NEXT_PUBLIC_LIBNAME env var not set') | ||
|
|
||
| const docs = await parseDocsMetadata(MDX) | ||
|
|
||
| const baseUrl = NEXT_PUBLIC_URL || '' | ||
|
|
||
| // Generate llms-full.txt content | ||
| const header = `${NEXT_PUBLIC_LIBNAME} | ||
|
|
||
| Full documentation content. | ||
|
|
||
| ` | ||
|
|
||
| const fullContent = | ||
| header + | ||
| docs | ||
| .map((doc) => { | ||
| const url = baseUrl ? `${baseUrl}${doc.url}` : doc.url | ||
| return `--- | ||
|
|
||
| ${doc.title} | ||
| URL: ${url} | ||
| ${doc.description ? `Description: ${doc.description}\n` : ''} | ||
| ${cleanMarkdown(doc.content)} | ||
| ` | ||
| }) | ||
| .join('\n') | ||
|
|
||
| return new Response(fullContent, { | ||
| headers: { | ||
| 'Content-Type': 'text/plain; charset=utf-8', | ||
| }, | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { parseDocsMetadata } from '@/utils/docs' | ||
|
|
||
| export const dynamic = 'force-static' | ||
|
|
||
| export async function GET() { | ||
| const { MDX, NEXT_PUBLIC_LIBNAME, NEXT_PUBLIC_URL } = process.env | ||
| if (!MDX) throw new Error('MDX env var not set') | ||
| if (!NEXT_PUBLIC_LIBNAME) throw new Error('NEXT_PUBLIC_LIBNAME env var not set') | ||
|
|
||
| const docs = await parseDocsMetadata(MDX) | ||
|
|
||
| const baseUrl = NEXT_PUBLIC_URL || '' | ||
|
|
||
| // Generate llms.txt content following standard format | ||
| const content = `# ${NEXT_PUBLIC_LIBNAME} | ||
|
|
||
| ## Documentation | ||
|
|
||
| ${docs | ||
| .map((doc) => { | ||
| const url = baseUrl ? `${baseUrl}${doc.url}` : doc.url | ||
| return `- [${doc.title}](${url})${doc.description ? `: ${doc.description}` : ''}` | ||
| }) | ||
| .join('\n')} | ||
|
|
||
| --- | ||
|
|
||
| For full documentation content, see ${baseUrl}/llms-full.txt | ||
| ` | ||
|
|
||
| return new Response(content, { | ||
| headers: { | ||
| 'Content-Type': 'text/plain; charset=utf-8', | ||
| }, | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot still necessary (you added this in a previous commit i think)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot if not, dont forget to update the lock file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in d408942. The
remark,remark-mdx, andremark-stringifydependencies were added in commit fad20a3 for JSX stripping but are no longer used after we simplified to keep all JSX tags as-is (commit def4a47). The current implementation only uses basic string operations, so these dependencies are unnecessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already done in d408942. The commit removed the dependencies from package.json and updated pnpm-lock.yaml (21 lines removed). Both files were committed together.