Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions scripts/generate-md-exports.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ ${

// Append child listings to parent index files
let updatedCount = 0;
const r2Uploads = [];
for (const [parentPath, children] of pathsByParent) {
const parentFile = path.join(OUTPUT_DIR, parentPath);
let existingContent;
Expand Down Expand Up @@ -348,17 +349,28 @@ ${
await writeFile(parentFile, updatedContent, {encoding: 'utf8'});
updatedCount++;

// Upload modified parent file to R2 if configured
// Collect R2 uploads needed (will be uploaded in parallel below)
if (accessKeyId && secretAccessKey && existingFilesOnR2) {
const fileHash = md5(updatedContent);
const existingHash = existingFilesOnR2.get(parentPath);
if (existingHash !== fileHash) {
const s3Client = getS3Client();
await uploadToCFR2(s3Client, parentPath, updatedContent);
r2Uploads.push({parentPath, updatedContent});
}
}
}
}

// Upload all modified section index files to R2 in parallel
if (r2Uploads.length > 0) {
const limit = pLimit(50);
const s3Client = getS3Client();
await Promise.all(
r2Uploads.map(({parentPath, updatedContent}) =>
limit(() => uploadToCFR2(s3Client, parentPath, updatedContent))
)
);
console.log(`📤 Uploaded ${r2Uploads.length} section index files to R2`);
}
console.log(`📑 Added child page listings to ${updatedCount} section index files`);

// Upload index.md to R2 if configured
Expand Down