Rebuilds content management around a single admin route (/admin — "BlackDice Studio"), replacing blackdice-studio.html. Publishing writes one JSON content document instead of regenerating HTML files, so it can no longer overwrite hand-made site changes the way the old tool did. - /admin: click-to-edit copy/images, article CRUD with a Word-safe rich text editor, demo clip management, per-page SEO, enquiry log, publish history with rollback - Real per-page URLs for all pages and articles, each with its own meta/canonical/OG/JSON-LD - Newsroom + article pages driven by the CMS post library, seeded from the old studio's export (17 articles) plus a drafted GSMA Open Gateway press release awaiting approval - Demo sections on Mobile SDK and Halo CPE, interactive by default and upgradable to an uploaded clip per slot - Dependency-free Node API server (auth, publish, uploads, snapshots, leads, live sitemap) - Deployment configs for Node/nginx/IIS, Vercel and Netlify See docs/ARCHITECTURE.md, docs/PROJECT-STRUCTURE.md, docs/CMS-GUIDE.md and docs/DEPLOYMENT.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
48 lines
2.0 KiB
JavaScript
48 lines
2.0 KiB
JavaScript
/**
|
|
* Writes public/sitemap.xml and public/robots.txt from the content that will ship
|
|
* in the build. The server also serves a live sitemap at /sitemap.xml (which picks
|
|
* up articles published after the build); this static copy is the fallback for
|
|
* static hosting and for crawlers hitting the file directly.
|
|
*
|
|
* node scripts/generate-sitemap.mjs [siteUrl]
|
|
*/
|
|
import fs from 'node:fs'
|
|
import path from 'node:path'
|
|
|
|
const ROOT = path.resolve(import.meta.dirname, '..')
|
|
const SITE_URL = (process.argv[2] || process.env.SITE_URL || 'https://www.blackdice.ai').replace(/\/+$/, '')
|
|
|
|
const PATHS = [
|
|
['/', '1.0'], ['/mobile-sdk', '0.9'], ['/dns-protect', '0.9'], ['/halo-cpe', '0.9'],
|
|
['/for-operators', '0.8'], ['/financial-services', '0.8'], ['/why-blackdice', '0.7'],
|
|
['/news', '0.8'], ['/investors', '0.6'], ['/contact', '0.7'],
|
|
]
|
|
|
|
const seed = JSON.parse(fs.readFileSync(path.join(ROOT, 'src/cms/generated/seedContent.json'), 'utf8'))
|
|
const live = (() => {
|
|
const file = path.join(ROOT, 'content/site-content.json')
|
|
return fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : null
|
|
})()
|
|
const posts = (live?.posts || seed.posts || []).filter((p) => p.status !== 'draft')
|
|
|
|
const today = new Date().toISOString().slice(0, 10)
|
|
const urls = [
|
|
...PATHS.map(([p, pri]) => ({ loc: SITE_URL + p, lastmod: today, pri })),
|
|
...posts.map((p) => ({
|
|
loc: `${SITE_URL}/blog/${p.slug}`,
|
|
lastmod: (p.updatedAt || p.date || today).slice(0, 10),
|
|
pri: '0.6',
|
|
})),
|
|
]
|
|
|
|
const xml =
|
|
'<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n' +
|
|
urls
|
|
.map((u) => ` <url>\n <loc>${u.loc}</loc>\n <lastmod>${u.lastmod}</lastmod>\n <priority>${u.pri}</priority>\n </url>`)
|
|
.join('\n') +
|
|
'\n</urlset>\n'
|
|
|
|
fs.writeFileSync(path.join(ROOT, 'public/sitemap.xml'), xml)
|
|
fs.writeFileSync(path.join(ROOT, 'public/robots.txt'), `User-agent: *\nAllow: /\n\nSitemap: ${SITE_URL}/sitemap.xml\n`)
|
|
console.log(`sitemap.xml: ${urls.length} URLs (${posts.length} articles) → ${SITE_URL}`)
|