@@ -56,11 +56,65 @@ export function getPagesForLLMSection(pages: LLMPageLike[], section?: string) {
5656 ) ;
5757}
5858
59+ function getExamplePathForSection ( section : string ) : string {
60+ const examples : Record < string , string > = {
61+ ios : "/docs/ios/guides/advanced/game-controller-support.md" ,
62+ android : "/docs/android/guides/advanced/game-controller-support.md" ,
63+ flutter : "/docs/flutter/guides/advanced/game-controller-support.md" ,
64+ expo : "/docs/expo/guides/advanced/game-controller-support.md" ,
65+ "react-native" : "/docs/react-native/guides/advanced/game-controller-support.md" ,
66+ dashboard : "/docs/dashboard/dashboard-settings/overview-settings-apple-search-ads.md" ,
67+ integrations : "/docs/integrations/amplitude.md" ,
68+ "web-checkout" : "/docs/web-checkout/overview.md" ,
69+ } ;
70+ return examples [ section ] ?? "/docs/android/guides/advanced/game-controller-support.md" ;
71+ }
72+
5973export function buildLLMSummaryTextFromPages ( pages : LLMPageLike [ ] , section ?: string ) {
6074 const config = getLLMSectionConfig ( section ) ;
61- const title = config ? `${ config . label } Documentation` : "Documentation" ;
75+ const title = config ? `${ config . label } Documentation` : "Superwall Documentation" ;
6276 const lines : string [ ] = [ `# ${ title } ` , "" ] ;
6377
78+ // Add Superwall description
79+ lines . push (
80+ "Superwall is a platform for remotely configuring and A/B testing mobile app paywalls — no app update required. It provides SDKs for iOS, Android, Flutter, Expo, and React Native, plus a dashboard for managing paywall presentation, experiments, and subscription analytics." ,
81+ "" ,
82+ ) ;
83+
84+ // Add markdown mirror instructions
85+ const examplePath = config
86+ ? getExamplePathForSection ( section ! )
87+ : "/docs/android/guides/advanced/game-controller-support.md" ;
88+ lines . push (
89+ "Curl the pages below to read docs for each page. You can request markdown files by appending .md to a route, for example:" ,
90+ "" ,
91+ `- https://superwall.com${ examplePath } ` ,
92+ "" ,
93+ "Note: Doc URLs return a 307 redirect. Always use `curl -sL` (follow redirects) when fetching them." ,
94+ "" ,
95+ ) ;
96+
97+ // Add links to all sections
98+ if ( ! config ) {
99+ // Top-level: list all platform-specific docs
100+ lines . push ( "## Platform-specific docs" , "" ) ;
101+ for ( const [ key , val ] of Object . entries ( llmsSectionConfigs ) ) {
102+ lines . push ( `- [${ val . label } Documentation](/docs/llms-${ key } .txt)` ) ;
103+ }
104+ lines . push ( "" , "## All Pages" , "" ) ;
105+ } else {
106+ // Section-specific: link back to top-level + list other sections
107+ lines . push ( "## Other sections" , "" ) ;
108+ lines . push ( "- [All Documentation](/docs/llms.txt)" ) ;
109+ for ( const [ key , val ] of Object . entries ( llmsSectionConfigs ) ) {
110+ if ( key !== section ) {
111+ lines . push ( `- [${ val . label } Documentation](/docs/llms-${ key } .txt)` ) ;
112+ }
113+ }
114+ lines . push ( "" ) ;
115+ }
116+
117+ // Page listing
64118 for ( const page of getPagesForLLMSection ( pages , section ) ) {
65119 const description = page . data . description ? `: ${ page . data . description } ` : "" ;
66120 lines . push ( `- [${ page . data . title } ](${ page . url } )${ description } ` ) ;
@@ -75,9 +129,13 @@ export async function buildLLMSummaryText(section?: string) {
75129}
76130
77131export async function buildLLMFullText ( section ?: string ) {
132+ const config = getLLMSectionConfig ( section ) ;
133+ const title = config ? `${ config . label } Documentation` : "Superwall Documentation" ;
78134 const { source, getLLMText } = await import ( "@/lib/source" ) ;
79- const scanned = await Promise . all ( getPagesForLLMSection ( source . getPages ( ) , section ) . map ( getLLMText ) ) ;
80- return scanned . join ( "\n\n" ) ;
135+ const scanned = await Promise . all (
136+ getPagesForLLMSection ( source . getPages ( ) , section ) . map ( getLLMText ) ,
137+ ) ;
138+ return `# ${ title } \n\n${ scanned . join ( "\n\n" ) } ` ;
81139}
82140
83141export function buildLLMResponse ( body : string ) {
0 commit comments