generated from chiffre-io/template-library
-
-
Notifications
You must be signed in to change notification settings - Fork 228
doc: support markdown response for AI #1171
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
Open
aryasaatvik
wants to merge
16
commits into
47ng:next
Choose a base branch
from
aryasaatvik:feat/llm-docs
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
439f2de
chore(deps): update fumadocs-core to 15.8.5 and fumadocs-mdx to 12.0.…
aryasaatvik 61a800d
feat(docs): implement LLM markdown rewrites and add new routes for LL…
aryasaatvik b0441c7
ref(docs): replace middleware with static rewrites for LLM content
aryasaatvik 24d0d0c
chore(deps): update fumadocs-ui to 15.8.5 in package.json and pnpm-lo…
aryasaatvik cb4dd17
chore: move llms.txt and llms-full.txt to the root
aryasaatvik a133fe4
feat(docs): add new redirect for manually requesting markdown files i…
aryasaatvik 9ee7547
feat(docs): add copy button and view options for markdown files
aryasaatvik 4bc7213
chore(docs): update test script to include next typegen before tsc
aryasaatvik 82b59ad
fix(docs): use consistent cn utility import
aryasaatvik 683b3dd
feat(docs): use nuqs serializer for ChatGPT URL construction
aryasaatvik 22ef450
feat(docs): add Suspense boundary with buttonVariants skeleton
aryasaatvik 5cd30b9
feat(docs): move PageActionsSkeleton to page-actions component
aryasaatvik 0027b7c
Merge branch 'next' into feat/llm-docs
aryasaatvik af1b68c
feat(docs): restructure LLM documentation output
aryasaatvik 82120b0
feat(docs): add page exclusions for LLM text generation
aryasaatvik bf1fac4
fix(docs): filter out excluded pages in LLM text generation
aryasaatvik 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
Some comments aren't visible on the classic Files Changed page.
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
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
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,12 @@ | ||
| import { source } from '@/src/app/source'; | ||
| import { getLLMText } from '@/src/lib/get-llm-text'; | ||
|
|
||
| // cached forever | ||
| export const revalidate = false; | ||
|
|
||
| export async function GET() { | ||
| const scan = source.getPages().map(getLLMText); | ||
| const scanned = await Promise.all(scan); | ||
|
|
||
| return new Response(scanned.join('\n\n')); | ||
| } |
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,24 @@ | ||
| import { getLLMText } from '@/src/lib/get-llm-text'; | ||
| import { source } from '@/src/app/source'; | ||
| import { notFound } from 'next/navigation'; | ||
|
|
||
| export const revalidate = false; | ||
|
|
||
| export async function GET( | ||
| _req: Request, | ||
| { params }: RouteContext<'/docs/llms.mdx/[[...slug]]'>, | ||
| ) { | ||
| const { slug } = await params; | ||
| const page = source.getPage(slug); | ||
| if (!page) notFound(); | ||
|
|
||
| return new Response(await getLLMText(page), { | ||
| headers: { | ||
| 'Content-Type': 'text/markdown', | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| export function generateStaticParams() { | ||
| return source.generateParams(); | ||
| } |
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,12 @@ | ||
| import { source } from '@/src/app/source'; | ||
| import { getLLMText } from '@/src/lib/get-llm-text'; | ||
|
|
||
| // cached forever | ||
| export const revalidate = false; | ||
|
|
||
| export async function GET() { | ||
| const scan = source.getPages().map(getLLMText); | ||
| const scanned = await Promise.all(scan); | ||
|
|
||
| return new Response(scanned.join('\n\n')); | ||
| } |
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,10 @@ | ||
| import type { source } from "@/src/app/source"; | ||
| import type { InferPageType } from "fumadocs-core/source";; | ||
|
|
||
| export async function getLLMText(page: InferPageType<typeof source>) { | ||
| const processed = await page.data.getText('processed'); | ||
|
|
||
| return `# ${page.data.title} (${page.url}) | ||
|
|
||
| ${processed}`; | ||
| } |
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,20 @@ | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
| import { isMarkdownPreferred, rewritePath } from "fumadocs-core/negotiation"; | ||
|
|
||
| const { rewrite: rewriteLLM } = rewritePath("/docs/*path", "/docs/llms.mdx/*path"); | ||
|
|
||
| export function middleware(request: NextRequest) { | ||
| if (isMarkdownPreferred(request)) { | ||
| const result = rewriteLLM(request.nextUrl.pathname); | ||
|
|
||
| if (result) { | ||
| return NextResponse.rewrite(new URL(result, request.nextUrl)); | ||
| } | ||
| } | ||
|
|
||
| return NextResponse.next(); | ||
| } | ||
|
|
||
| export const config = { | ||
| matcher: "/docs/:path*", | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
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.
question: What does this function do?
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.
it checks the Accept header for the presence of text/plain or text/markdown preference and the order and q value if both text/html and (text/plain or text/markdown) are present.
using a static rewrite also works for claude code and opencode since they dont rely on q value and order