add sitemap and robots.txt
This commit is contained in:
parent
a6e5fe1d45
commit
e02d6fe283
5 changed files with 47 additions and 4 deletions
|
@ -76,8 +76,9 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
preset: 'bun',
|
preset: 'bun',
|
||||||
// prerender: {
|
prerender: {
|
||||||
// crawlLinks: true,
|
crawlLinks: false,
|
||||||
// },
|
routes: ['/sitemap.xml']
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
@ -6,10 +6,11 @@
|
||||||
"@solidjs/start": "^1.0.10",
|
"@solidjs/start": "^1.0.10",
|
||||||
"dexie": "^4.0.10",
|
"dexie": "^4.0.10",
|
||||||
"iterator-helpers-polyfill": "^3.0.1",
|
"iterator-helpers-polyfill": "^3.0.1",
|
||||||
|
"sitemap": "^8.0.0",
|
||||||
"solid-icons": "^1.1.0",
|
"solid-icons": "^1.1.0",
|
||||||
"solid-js": "^1.9.3",
|
"solid-js": "^1.9.3",
|
||||||
"ts-pattern": "^5.5.0",
|
"ts-pattern": "^5.5.0",
|
||||||
"vinxi": "^0.5.0"
|
"vinxi": "^0.4.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
|
|
5
public/.well-known/robots.txt
Normal file
5
public/.well-known/robots.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
robots.txt generated by www.seoptimer.com
|
||||||
|
User-agent: *
|
||||||
|
Disallow:
|
||||||
|
Disallow: /cgi-bin/
|
||||||
|
Sitemap: https://www.example.com/sitemap.xml
|
36
src/routes/sitemap.xml.ts
Normal file
36
src/routes/sitemap.xml.ts
Normal file
|
@ -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, ''));
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue