File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ Important Notes:
1919 for ( const page of source . getPages ( ) ) {
2020 const dir = page . slugs [ 0 ] ;
2121 const list = map . get ( dir ) ?? [ ] ;
22- list . push ( `- [${ page . data . title } ](${ page . url } ): ${ page . data . description } ` ) ;
22+ list . push (
23+ `- [${ page . data . title } ](${ page . url } .md): ${ page . data . description } ` ,
24+ ) ;
2325 map . set ( dir , list ) ;
2426 }
2527
Original file line number Diff line number Diff line change 1+ import { getLLMText , source } from "@/lib/source/docs" ;
2+ import type { NextRequest } from "next/server" ;
3+
4+ export async function proxy ( request : NextRequest ) {
5+ const { pathname } = request . nextUrl ;
6+
7+ if ( ! pathname . endsWith ( ".md" ) ) {
8+ return ;
9+ }
10+
11+ const slug = pathname . slice ( 0 , - 3 ) . split ( "/" ) . filter ( Boolean ) . slice ( 1 ) ;
12+
13+ const page = source . getPage ( slug ) ;
14+ if ( ! page ) {
15+ return new Response ( "Not Found" , { status : 404 } ) ;
16+ }
17+
18+ const markdown = await getLLMText ( page ) ;
19+
20+ return new Response ( markdown , {
21+ headers : {
22+ "Content-Type" : "text/markdown; charset=utf-8" ,
23+ } ,
24+ } ) ;
25+ }
26+
27+ export const config = {
28+ matcher : [ "/docs/:path*" , "/docs" , "/docs.md" ] ,
29+ } ;
You can’t perform that action at this time.
0 commit comments