@@ -118,6 +118,41 @@ export function generateImportStatements(
118118 return statements . length > 0 ? `${ statements . join ( '\n' ) } \n\n` : ''
119119}
120120
121+ type AnnotatedNode = SceneNode & {
122+ annotations : ReadonlyArray < { label ?: string ; labelMarkdown ?: string } >
123+ }
124+
125+ /**
126+ * Collect notes from a section: standalone TEXT children (annotations by convention)
127+ * and Figma dev-mode annotations on descendant nodes.
128+ * Returns the combined text, or empty string if none found.
129+ */
130+ export function collectSectionNotes ( section : SectionNode ) : string {
131+ const lines : string [ ] = [ ]
132+
133+ // 1. Direct TEXT children are treated as page annotations
134+ for ( const child of section . children ) {
135+ if ( child . type === 'TEXT' ) {
136+ const text = ( child as TextNode ) . characters . trim ( )
137+ if ( text ) lines . push ( text )
138+ }
139+ }
140+
141+ // 2. Figma dev-mode annotations on any descendant node
142+ const annotatedNodes = section . findAll (
143+ ( node ) =>
144+ 'annotations' in node && ( node as AnnotatedNode ) . annotations . length > 0 ,
145+ )
146+ for ( const node of annotatedNodes ) {
147+ for ( const annotation of ( node as AnnotatedNode ) . annotations ) {
148+ const text = ( annotation . label ?? annotation . labelMarkdown ?? '' ) . trim ( )
149+ if ( text ) lines . push ( `[${ node . name } ] ${ text } ` )
150+ }
151+ }
152+
153+ return lines . join ( '\n' )
154+ }
155+
121156interface ScreenshotTarget {
122157 node : SceneNode
123158 folder : JSZip
@@ -324,6 +359,12 @@ export async function exportPagesAndComponents() {
324359 pagesFolder ?. file ( `${ pageName } .tsx` , fullCode , ZIP_TEXT_FILE_OPTIONS )
325360 perfEnd ( `responsivePage(${ pageName } )` , t )
326361
362+ // Collect section notes (standalone TEXT children + annotations)
363+ const notes = collectSectionNotes ( sectionNode )
364+ if ( notes && pagesFolder ) {
365+ pagesFolder . file ( `${ pageName } .txt` , notes , ZIP_TEXT_FILE_OPTIONS )
366+ }
367+
327368 // Defer screenshot capture
328369 if ( pagesFolder ) {
329370 screenshotTargets . push ( {
0 commit comments