File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ import type { APIRoute } from "astro" ;
2+ import type { InferGetStaticPropsType , GetStaticPaths } from "astro" ;
3+
4+ import { getCollection } from "astro:content" ;
5+
6+ export const getStaticPaths = ( async ( ) => {
7+ const entries = await getCollection ( "docs" ) ;
8+
9+ return entries . map ( ( entry ) => {
10+ return {
11+ params : {
12+ // https://llmstxt.org/: (URLs without file names should append index.html.md instead.)
13+ entry : entry . slug + "/index" ,
14+ } ,
15+ props : {
16+ entry,
17+ } ,
18+ } ;
19+ } ) ;
20+ } ) satisfies GetStaticPaths ;
21+
22+ type Props = InferGetStaticPropsType < typeof getStaticPaths > ;
23+
24+ export const GET : APIRoute < Props > = ( context ) => {
25+ return new Response ( context . props . entry . body , {
26+ headers : {
27+ "content-type" : "text/markdown" ,
28+ } ,
29+ } ) ;
30+ } ;
Original file line number Diff line number Diff line change 1+ import type { APIRoute } from "astro" ;
2+ import { getCollection } from "astro:content" ;
3+
4+ export const GET : APIRoute = async ( ) => {
5+ const markdown = await getCollection ( "docs" )
6+ . then ( ( entries ) => entries . map ( ( entry ) => entry . body ) )
7+ . then ( ( array ) => array . join ( "\n\n" ) ) ;
8+
9+ return new Response ( markdown , {
10+ headers : {
11+ "content-type" : "text/plain" ,
12+ } ,
13+ } ) ;
14+ } ;
You can’t perform that action at this time.
0 commit comments