diff --git a/app.config.ts b/app.config.ts index 56b652b..01b146e 100644 --- a/app.config.ts +++ b/app.config.ts @@ -76,8 +76,9 @@ export default defineConfig({ }, server: { preset: 'bun', - // prerender: { - // crawlLinks: true, - // }, + prerender: { + crawlLinks: false, + routes: ['/sitemap.xml'] + }, }, }); diff --git a/bun.lockb b/bun.lockb index 8079073..9b87d97 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 45e031e..6f0ea11 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,11 @@ "@solidjs/start": "^1.0.10", "dexie": "^4.0.10", "iterator-helpers-polyfill": "^3.0.1", + "sitemap": "^8.0.0", "solid-icons": "^1.1.0", "solid-js": "^1.9.3", "ts-pattern": "^5.5.0", - "vinxi": "^0.5.0" + "vinxi": "^0.4.3" }, "engines": { "node": ">=18" diff --git a/public/.well-known/robots.txt b/public/.well-known/robots.txt new file mode 100644 index 0000000..58ec122 --- /dev/null +++ b/public/.well-known/robots.txt @@ -0,0 +1,5 @@ +robots.txt generated by www.seoptimer.com +User-agent: * +Disallow: +Disallow: /cgi-bin/ +Sitemap: https://www.example.com/sitemap.xml diff --git a/src/routes/sitemap.xml.ts b/src/routes/sitemap.xml.ts new file mode 100644 index 0000000..4cdfeea --- /dev/null +++ b/src/routes/sitemap.xml.ts @@ -0,0 +1,36 @@ +import { SitemapStream, streamToPromise } from 'sitemap' +import { App } from 'vinxi'; + +const BASE_URL = 'https://ca-euw-prd-calque-app.purplecoast-f5b7f657.westeurope.azurecontainerapps.io'; + +export async function GET() { + + const sitemap = new SitemapStream({ hostname: BASE_URL }); + + sitemap.write({ url: BASE_URL, changefreq: 'monthly', }); + + for (const route of await getRoutes()) { + sitemap.write({ url: route, changefreq: 'monthly', }); + } + + sitemap.end(); + + return new Response( + (await streamToPromise(sitemap)).toString(), + { status: 200, headers: { 'Content-Type': 'text/xml' } } + ); +} + +const getRoutes = async () => { + const router = ((globalThis as any).app as App).getRouter('client').internals.routes; + + if (router === undefined) { + return []; + } + + const routes = await router.getRoutes() as { page: boolean, $$route?: object, path: string }[]; + + return routes + .filter(r => r.page === true && r.$$route === undefined && !r.path.match(/^.+\*\d+$/)) + .map(r => r.path.replace(/\/\(\w+\)/g, '')); +}; \ No newline at end of file