Fixes SeoHead (title/canonical/hreflang/JSON-LD) to render during SSR via vite-react-ssg's Head component instead of a client-only useEffect, so crawlers see real tags without executing JS. Also fixes an SSR crash in useTheme (localStorage access with no window during server render) and removes now-duplicated static meta tags from index.html.
32 lines
954 B
JavaScript
32 lines
954 B
JavaScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { listAllRoutePaths } from './src/data/routePaths.js';
|
|
|
|
const SITE_URL = 'https://convert.ombrora.com';
|
|
|
|
function writeSitemap(outDir) {
|
|
const paths = listAllRoutePaths();
|
|
const lastmod = new Date().toISOString().slice(0, 10);
|
|
const urls = paths
|
|
.map((p) => ` <url>\n <loc>${SITE_URL}${p}/</loc>\n <lastmod>${lastmod}</lastmod>\n </url>`)
|
|
.join('\n');
|
|
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls}\n</urlset>\n`;
|
|
fs.writeFileSync(path.join(outDir, 'sitemap.xml'), sitemap);
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
server: {
|
|
proxy: {
|
|
'/api': 'http://localhost:3000',
|
|
},
|
|
},
|
|
ssgOptions: {
|
|
dirStyle: 'nested',
|
|
script: 'async',
|
|
onFinished: writeSitemap,
|
|
},
|
|
});
|