mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
f4937949d6
* Add timer setting * Setup benchmark code * Setup memory benchmark * Add compare function * Add result preview * Setup results preview * Simplify script for CI * Update CI * Cleanup * Temp remove fork guard * Fix stuff * Fix again * Fix quotes * Fix multiline output * Simplify title * Fix memory numbers * Remove astro bin dir * Fix gc * Add repo guards * Fix wrong call * Set max space size * Remove guard * Bump memory a bit * Organize neatly * Update readme * Try large md * Try no gc * Revert markdown and gc changes * Test sha * Try ref * Try 128mb * Set 256 * Add guard * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Add docs comment --------- Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
import fs from 'fs/promises';
|
|
import { loremIpsum } from './_util.js';
|
|
|
|
/**
|
|
* @param {URL} projectDir
|
|
*/
|
|
export async function run(projectDir) {
|
|
await fs.rm(projectDir, { recursive: true, force: true });
|
|
await fs.mkdir(new URL('./src/pages/blog', projectDir), { recursive: true });
|
|
await fs.mkdir(new URL('./src/content/blog', projectDir), { recursive: true });
|
|
|
|
const promises = [];
|
|
|
|
for (let i = 0; i < 100; i++) {
|
|
const content = `\
|
|
---
|
|
const i = ${i};
|
|
---
|
|
|
|
<span>{i}</span>
|
|
`;
|
|
promises.push(
|
|
fs.writeFile(new URL(`./src/pages/page-${i}.astro`, projectDir), content, 'utf-8')
|
|
);
|
|
}
|
|
|
|
for (let i = 0; i < 100; i++) {
|
|
const content = `\
|
|
# Article ${i}
|
|
|
|
${loremIpsum}
|
|
`;
|
|
promises.push(
|
|
fs.writeFile(new URL(`./src/content/blog/article-${i}.md`, projectDir), content, 'utf-8')
|
|
);
|
|
}
|
|
|
|
await fs.writeFile(
|
|
new URL(`./src/pages/blog/[...slug].astro`, projectDir),
|
|
`\
|
|
---
|
|
import { getCollection } from 'astro:content';
|
|
export async function getStaticPaths() {
|
|
const blogEntries = await getCollection('blog');
|
|
return blogEntries.map(entry => ({
|
|
params: { slug: entry.slug }, props: { entry },
|
|
}));
|
|
}
|
|
const { entry } = Astro.props;
|
|
const { Content } = await entry.render();
|
|
---
|
|
<h1>{entry.data.title}</h1>
|
|
<Content />
|
|
`,
|
|
'utf-8'
|
|
);
|
|
|
|
await Promise.all(promises);
|
|
}
|