Original beynar's repo with fixes.
This product is a library designed to help generate and maintain dynamic sitemap.xml and robots.txt files for SvelteKit apps. It consists of a Vite plugin and a Svelte-kit hook. The plugin watches the routes folder and generates a typescript representation of it, while the hook delivers sitemap.xml and robots.txt responses based on the params and the typescript sitemap.
To use this library, follow these steps:
// vite.config.js
import { sitemapPlugin } from 'sveltekit-sitemap';
export default {
plugins: [
svelte(),
sitemapPlugin({
routesDir: './src/routes',
sitemapFile: './src/sitemap.ts',
}),
],
};
import { sitemapHook } from 'sveltekit-sitemap';
export function hooks() {
sitemapHook({
routes: getRoutes,
robots: getRobots,
});
}
The sveltekit-sitemap library is a useful tool for generating and maintaining dynamic sitemap.xml and robots.txt files for SvelteKit apps. It provides a Vite plugin for generating a typescript representation of the routes and a Svelte-kit hook for delivering the sitemap and robots.txt responses. The library is configurable and allows for the definition of custom routes and robots directives.