@@ -38,7 +38,7 @@ async function downloadAndProcessImage(url, blockName, index) {
3838 const filepath = path . join ( IMAGES_PATH , filename ) ;
3939
4040 spinner . text = `Processing image ${ index + 1 } : Resizing` ;
41- const { outputBuffer : resizedBuffer , originalSize, processedSize } = await processImage ( buffer , filepath ) ;
41+ const { outputBuffer : resizedBuffer , originalSize } = await processImage ( buffer , filepath ) ;
4242
4343 spinner . text = `Processing image ${ index + 1 } : Compressing` ;
4444 const { compressedBuffer, compressedSize } = await compressImage ( resizedBuffer , filepath ) ;
@@ -60,22 +60,22 @@ async function downloadAndProcessImage(url, blockName, index) {
6060export async function generateBlocks ( data , progressCallback ) {
6161 const totalPages = data . length ;
6262 let totalSaved = 0 ;
63-
63+
6464 // Variables to track section folders and title metadata
6565 let currentSectionFolder = null ;
6666 let nextItemTitle = null ;
67-
67+
6868 // Stats for reporting
6969 let sectionCount = 0 ;
7070 let titleSectionCount = 0 ;
71-
71+
7272 // Data is already sorted by Order property in fetchNotion.ts
7373
7474 for ( let i = 0 ; i < totalPages ; i ++ ) {
7575 const page = data [ i ] ;
76- console . log ( chalk . blue ( `Processing page: ${ page . id } , ${ page . properties [ 'Name ' ] . title [ 0 ] . plain_text } ` ) ) ;
76+ console . log ( chalk . blue ( `Processing page: ${ page . id } , ${ page . properties [ 'Title ' ] . title [ 0 ] . plain_text } ` ) ) ;
7777 const pageSpinner = ora ( `Processing page ${ i + 1 } /${ totalPages } ` ) . start ( ) ;
78- const websiteBlock = page . properties [ 'Name ' ] . title [ 0 ] . plain_text
78+ const websiteBlock = page . properties [ 'Title ' ] . title [ 0 ] . plain_text
7979 . toLowerCase ( )
8080 . replace ( / \s + / g, '-' )
8181 . replace ( / [ ^ a - z 0 - 9 - ] / g, '' ) ;
@@ -85,15 +85,15 @@ export async function generateBlocks(data, progressCallback) {
8585 const sectionType = page . properties [ 'Section' ] . select . name . toLowerCase ( ) ;
8686 if ( sectionType === 'toggle' ) {
8787 // A toggle section creates a folder and applies to all subsequent items until a new Section is encountered
88- const sectionName = page . properties [ 'Name ' ] . title [ 0 ] . plain_text ;
88+ const sectionName = page . properties [ 'Title ' ] . title [ 0 ] . plain_text ;
8989 const sectionFolder = websiteBlock ;
9090 const sectionFolderPath = path . join ( CONTENT_PATH , sectionFolder ) ;
9191 fs . mkdirSync ( sectionFolderPath , { recursive : true } ) ;
92-
92+
9393 // Update the current section folder so that subsequent items are placed here
9494 currentSectionFolder = sectionFolder ;
9595 sectionCount ++ ; // Increment section counter
96-
96+
9797 // Extract icon if available
9898 let icon = null ;
9999 if ( page . properties [ 'Icon' ] && page . properties [ 'Icon' ] . rich_text && page . properties [ 'Icon' ] . rich_text . length > 0 ) {
@@ -112,41 +112,41 @@ export async function generateBlocks(data, progressCallback) {
112112 title : sectionName
113113 }
114114 } ;
115-
115+
116116 // Apply title from a previous title section if available
117117 if ( nextItemTitle ) {
118118 categoryContent . customProps . title = nextItemTitle ;
119119 nextItemTitle = null ; // Reset after using it
120120 }
121-
121+
122122 // Add icon if available
123123 if ( icon ) {
124124 categoryContent . customProps . icon = icon ;
125125 }
126-
126+
127127 const categoryFilePath = path . join ( sectionFolderPath , "_category_.json" ) ;
128128 fs . writeFileSync ( categoryFilePath , JSON . stringify ( categoryContent , null , 2 ) , 'utf8' ) ;
129129 pageSpinner . succeed ( chalk . green ( `Section folder created: ${ sectionFolder } with _category_.json` ) ) ;
130130 progressCallback ( { current : i + 1 , total : totalPages } ) ;
131131 continue ; // Skip creating a markdown file for this section item
132132 }
133-
133+
134134 if ( sectionType === 'title' ) {
135135 // A title section does not create its own folder. Instead, its name will be used as metadata
136136 // for the next non-section item.
137137 currentSectionFolder = null ;
138- nextItemTitle = page . properties . Name . title [ 0 ] . plain_text ;
138+ nextItemTitle = page . properties . Title . title [ 0 ] . plain_text ;
139139 // Don't reset the current section folder, keep items in the current toggle folder if applicable
140140 titleSectionCount ++ ; // Increment title section counter
141141 pageSpinner . succeed ( chalk . green ( `Title section detected: ${ nextItemTitle } , will be applied to next item` ) ) ;
142142 progressCallback ( { current : i + 1 , total : totalPages } ) ;
143143 continue ; // Skip creating markdown file for this title section item
144144 }
145-
145+
146146 // If we encounter any other section type, clear the section folder to place items at root level
147147 currentSectionFolder = null ;
148148 }
149-
149+
150150 const markdown = await n2m . pageToMarkdown ( page . id ) ;
151151 const markdownString = n2m . toMarkdownString ( markdown ) ;
152152 if ( markdownString ?. parent ) {
@@ -169,25 +169,25 @@ export async function generateBlocks(data, progressCallback) {
169169 imgIndex ++ ;
170170 }
171171 await Promise . all ( imgPromises ) ;
172-
172+
173173 // Determine file path based on section folder context
174- let fileName = `${ websiteBlock } .md` ;
174+ const fileName = `${ websiteBlock } .md` ;
175175 let filePath ;
176-
176+
177177 if ( currentSectionFolder ) {
178178 filePath = path . join ( CONTENT_PATH , currentSectionFolder , fileName ) ;
179179 } else {
180180 filePath = path . join ( CONTENT_PATH , fileName ) ;
181181 }
182182
183183 // Generate frontmatter
184- const pageTitle = page . properties [ 'Name ' ] . title [ 0 ] . plain_text ;
184+ const pageTitle = page . properties [ 'Title ' ] . title [ 0 ] . plain_text ;
185185
186186 // Extract additional properties if available
187187 let keywords = [ 'docs' , 'comapeo' ] ;
188188 let tags = [ 'comapeo' ] ;
189189 let sidebarPosition = i + 1 ;
190- let customProps = { } ;
190+ const customProps = { } ;
191191
192192 // Check for Tags property
193193 if ( page . properties [ 'Tags' ] && page . properties [ 'Tags' ] . multi_select ) {
@@ -203,20 +203,20 @@ export async function generateBlocks(data, progressCallback) {
203203 if ( page . properties [ 'Order' ] && page . properties [ 'Order' ] . number ) {
204204 sidebarPosition = page . properties [ 'Order' ] . number ;
205205 }
206-
206+
207207 // Check for Icon property
208208 if ( page . properties [ 'Icon' ] && page . properties [ 'Icon' ] . rich_text && page . properties [ 'Icon' ] . rich_text . length > 0 ) {
209209 customProps . icon = page . properties [ 'Icon' ] . rich_text [ 0 ] . plain_text ;
210210 }
211-
211+
212212 // Apply title from a previous title section if available
213213 if ( nextItemTitle ) {
214214 customProps . title = nextItemTitle ;
215215 nextItemTitle = null ; // Reset after using it
216216 }
217-
217+
218218 // Determine the relative path for the custom_edit_url
219- const relativePath = currentSectionFolder
219+ const relativePath = currentSectionFolder
220220 ? `${ currentSectionFolder } /${ fileName } `
221221 : fileName ;
222222
@@ -279,12 +279,12 @@ last_update:
279279
280280 pageSpinner . succeed ( chalk . green ( `Page ${ i + 1 } /${ totalPages } processed: ${ filePath } ` ) ) ;
281281 console . log ( chalk . blue ( ` ↳ Added frontmatter with id: doc-${ websiteBlock } , title: ${ pageTitle } ` ) ) ;
282-
282+
283283 // Log information about custom properties
284284 if ( Object . keys ( customProps ) . length > 0 ) {
285285 console . log ( chalk . yellow ( ` ↳ Added custom properties: ${ JSON . stringify ( customProps ) } ` ) ) ;
286286 }
287-
287+
288288 // Log information about section folder placement
289289 if ( currentSectionFolder ) {
290290 console . log ( chalk . cyan ( ` ↳ Placed in section folder: ${ currentSectionFolder } ` ) ) ;
0 commit comments