62 lines
1.5 KiB
JavaScript
Executable File
62 lines
1.5 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
const slug = process.argv[2];
|
|
|
|
if (!slug) {
|
|
console.error('Usage: node ./scripts/new-landing-page.mjs <slug>');
|
|
process.exit(1);
|
|
}
|
|
|
|
if (!/^[a-z0-9-]+$/.test(slug)) {
|
|
console.error('Slug must use lowercase letters, numbers, and hyphens only.');
|
|
process.exit(1);
|
|
}
|
|
|
|
const root = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..');
|
|
const target = path.join(root, 'content', 'landing-pages', `${slug}.json`);
|
|
|
|
if (fs.existsSync(target)) {
|
|
console.error(`Landing page already exists: ${target}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
const template = {
|
|
slug,
|
|
theme: 'ember',
|
|
eyebrow: 'Campaign',
|
|
title: 'Add your landing page headline here.',
|
|
summary: 'Summarize what this page is for and what action the visitor should take.',
|
|
highlight: 'One concise line that explains the page value.',
|
|
cta: {
|
|
label: 'Primary action',
|
|
href: 'https://www.haiyihy.com/',
|
|
},
|
|
secondaryCta: {
|
|
label: 'Secondary action',
|
|
href: 'https://h5.haiyihy.com/',
|
|
},
|
|
stats: [
|
|
{
|
|
value: 'Fast',
|
|
label: 'update-safe content model',
|
|
},
|
|
{
|
|
value: 'JSON',
|
|
label: 'driven page editing',
|
|
},
|
|
],
|
|
sections: [
|
|
{
|
|
title: 'Section title',
|
|
body: 'Describe the section content here.',
|
|
bullets: ['Optional bullet 1', 'Optional bullet 2'],
|
|
},
|
|
],
|
|
};
|
|
|
|
fs.writeFileSync(target, `${JSON.stringify(template, null, 2)}\n`, 'utf8');
|
|
console.log(`Created ${target}`);
|