generatePosts() — astro Function Reference
Architecture documentation for the generatePosts() function in generate-posts.mjs from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 2d88dc27_faa3_1ba8_2029_e9a5f69084d4["generatePosts()"] 0ae34de5_4ab6_7f40_1864_6596049615f5["generate-posts.mjs"] 2d88dc27_faa3_1ba8_2029_e9a5f69084d4 -->|defined in| 0ae34de5_4ab6_7f40_1864_6596049615f5 6d277f3d_88f9_05d3_9a12_e441d72b9900["benchmark()"] 6d277f3d_88f9_05d3_9a12_e441d72b9900 -->|calls| 2d88dc27_faa3_1ba8_2029_e9a5f69084d4 style 2d88dc27_faa3_1ba8_2029_e9a5f69084d4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/performance/scripts/generate-posts.mjs lines 9–30
export async function generatePosts({
postsDir = POSTS_DIR,
numPosts = NUM_POSTS,
ext = EXT,
template = TEMPLATE,
}) {
if (fs.existsSync(postsDir)) {
const files = await fs.promises.readdir(postsDir);
await Promise.all(files.map((file) => fs.promises.unlink(path.join(postsDir, file))));
} else {
await fs.promises.mkdir(postsDir, { recursive: true });
}
await Promise.all(
Array.from(Array(numPosts).keys()).map((idx) => {
return fs.promises.writeFile(
`${postsDir}/post-${idx}${ext.startsWith('.') ? ext : `.${ext}`}`,
fs.readFileSync(new URL(`./templates/${template}`, import.meta.url), 'utf8'),
);
}),
);
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does generatePosts() do?
generatePosts() is a function in the astro codebase, defined in packages/astro/performance/scripts/generate-posts.mjs.
Where is generatePosts() defined?
generatePosts() is defined in packages/astro/performance/scripts/generate-posts.mjs at line 9.
What calls generatePosts()?
generatePosts() is called by 1 function(s): benchmark.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free