Sveltekit Sitemap

screenshot of Sveltekit Sitemap

Overview

The sveltekit-sitemap library is designed to assist in generating and maintaining dynamic sitemap.xml and robots.txt files for SvelteKit apps. It combines a Vite plugin and a Svelte-kit hook to achieve this functionality. 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 params and the TypeScript sitemap. It is important to note that this library does not generate a static sitemap at build time, but rather helps deliver server-side rendered (SSR) sitemaps.

Features

  • Vite plugin to watch routes folder and generate a TypeScript representation of it.
  • Svelte-kit hook to deliver sitemap.xml and robots.txt responses based on params and the TypeScript sitemap.
  • Supports custom routes definitions and robots directives.
  • Allows for asynchronous functions to return route definitions and user-agent directives.

Summary

The sveltekit-sitemap library is a useful tool for generating and maintaining dynamic sitemap.xml and robots.txt files for SvelteKit apps. It combines a Vite plugin and a Svelte-kit hook to accomplish this functionality. 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 params and the TypeScript sitemap. It supports custom routes definitions and robots directives, allowing for flexible configurations.