File tree Expand file tree Collapse file tree 3 files changed +77
-0
lines changed
eventcatalog/src/pages/docs Expand file tree Collapse file tree 3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @eventcatalog/core " : patch
3+ ---
4+
5+ fix(core): mdx pages are added to teams and users
Original file line number Diff line number Diff line change 1+ // This file exposes the markdown for EventCatalog in the Url
2+ // For example http://localhost:3000/docs/teams/full-stack loads the Page and http://localhost:3000/docs/teams/full-stack.mdx loads the markdown
3+ // This is used for the LLMs to load the markdown for the given item (llms.txt);
4+
5+ import type { APIRoute } from 'astro' ;
6+ import { getCollection } from 'astro:content' ;
7+ import config from '@config' ;
8+ import fs from 'fs' ;
9+
10+ const teams = await getCollection ( 'teams' ) ;
11+
12+ export async function getStaticPaths ( ) {
13+ // Just return empty array if LLMs are not enabled
14+ if ( ! config . llmsTxt ?. enabled ) {
15+ return [ ] ;
16+ }
17+
18+ return teams . map ( ( team ) => ( {
19+ params : { type : 'teams' , id : team . data . id } ,
20+ props : { content : team } ,
21+ } ) ) ;
22+ }
23+
24+ export const GET : APIRoute = async ( { params, props } ) => {
25+ // Just return empty array if LLMs are not enabled
26+ if ( ! config . llmsTxt ?. enabled ) {
27+ return new Response ( 'llms.txt is not enabled for this Catalog.' , { status : 404 } ) ;
28+ }
29+
30+ if ( props ?. content ?. filePath ) {
31+ const file = fs . readFileSync ( props . content . filePath , 'utf8' ) ;
32+ return new Response ( file , { status : 200 } ) ;
33+ }
34+
35+ return new Response ( 'Not found' , { status : 404 } ) ;
36+ } ;
Original file line number Diff line number Diff line change 1+ // This file exposes the markdown for EventCatalog in the Url
2+ // For example http://localhost:3000/docs/users/dboyne loads the Page and http://localhost:3000/docs/users/dboyne.mdx loads the markdown
3+ // This is used for the LLMs to load the markdown for the given item (llms.txt);
4+
5+ import type { APIRoute } from 'astro' ;
6+ import { getCollection } from 'astro:content' ;
7+ import config from '@config' ;
8+ import fs from 'fs' ;
9+
10+ const users = await getCollection ( 'users' ) ;
11+
12+ export async function getStaticPaths ( ) {
13+ // Just return empty array if LLMs are not enabled
14+ if ( ! config . llmsTxt ?. enabled ) {
15+ return [ ] ;
16+ }
17+
18+ return users . map ( ( user ) => ( {
19+ params : { type : 'users' , id : user . data . id } ,
20+ props : { content : user } ,
21+ } ) ) ;
22+ }
23+
24+ export const GET : APIRoute = async ( { params, props } ) => {
25+ // Just return empty array if LLMs are not enabled
26+ if ( ! config . llmsTxt ?. enabled ) {
27+ return new Response ( 'llms.txt is not enabled for this Catalog.' , { status : 404 } ) ;
28+ }
29+
30+ if ( props ?. content ?. filePath ) {
31+ const file = fs . readFileSync ( props . content ?. filePath , 'utf8' ) ;
32+ return new Response ( file , { status : 200 } ) ;
33+ }
34+
35+ return new Response ( 'Not found' , { status : 404 } ) ;
36+ } ;
You can’t perform that action at this time.
0 commit comments