11import type { AstroGlobal } from "astro" ;
22import type { Props } from "@astrojs/starlight/props" ;
33
4- import { getEntry } from "astro:content" ;
4+ import { getEntry , getCollection } from "astro:content" ;
55import { rehypeExternalLinksOptions } from "~/plugins/rehype/external-links" ;
66
77type Link = Extract < Props [ "sidebar" ] [ 0 ] , { type : "link" } > & { order ?: number } ;
@@ -12,6 +12,7 @@ type Group = Extract<Props["sidebar"][0], { type: "group" }> & {
1212export type SidebarEntry = Link | Group ;
1313type Badge = Link [ "badge" ] ;
1414
15+ const products = await getCollection ( "products" ) ;
1516const sidebars = new Map < string , Group > ( ) ;
1617
1718export async function getSidebar ( context : AstroGlobal < Props > ) {
@@ -88,6 +89,33 @@ export async function generateSidebar(group: Group) {
8889 group . entries [ 0 ] . label = "Overview" ;
8990 }
9091
92+ const product = products . find ( ( p ) => p . id === group . label ) ;
93+ if ( product && product . data . product . group === "Developer platform" ) {
94+ const links = [
95+ [ "llms.txt" , "/llms.txt" ] ,
96+ [ "prompt.txt" , "/workers/prompt.txt" ] ,
97+ [ `${ product . data . name } llms-full.txt` , `/${ product . id } /llms-full.txt` ] ,
98+ [ "Developer Platform llms-full.txt" , "/developer-platform/llms-full.txt" ] ,
99+ ] ;
100+
101+ group . entries . push ( {
102+ type : "group" ,
103+ label : "LLM resources" ,
104+ entries : links . map ( ( [ label , href ] ) => ( {
105+ type : "link" ,
106+ label,
107+ href,
108+ isCurrent : false ,
109+ attrs : {
110+ target : "_blank" ,
111+ } ,
112+ badge : undefined ,
113+ } ) ) ,
114+ collapsed : true ,
115+ badge : undefined ,
116+ } ) ;
117+ }
118+
91119 return group ;
92120}
93121
0 commit comments