21 lines
786 B
JavaScript
21 lines
786 B
JavaScript
import { mkdir, writeFile } from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const projectRoot = path.resolve(__dirname, '..');
|
|
const outputPath = process.argv[2]
|
|
? path.resolve(process.argv[2])
|
|
: path.join(projectRoot, 'deploy-data', 'homepage-content.json');
|
|
|
|
const homepageModuleUrl = pathToFileURL(
|
|
path.join(projectRoot, 'src', 'lib', 'content', 'homepage.ts')
|
|
).href;
|
|
|
|
const { homepageContent } = await import(homepageModuleUrl);
|
|
|
|
await mkdir(path.dirname(outputPath), { recursive: true });
|
|
await writeFile(outputPath, `${JSON.stringify(homepageContent, null, 2)}\n`, 'utf8');
|
|
|
|
console.log(`[deploy] Exported homepage content to ${outputPath}`);
|