feat: SitemapPlugin path and sitemap index options
BE
2d ago+313+313+012345678901234567890123456789-6-6-0123456789
The SitemapPlugin always writes public/sitemap.xml. A site served by more than one backend, say a Reflex app for most pages and a CMS for a blog under the same domain, usually publishes a sitemap per part and a sitemap index at /sitemap.xml that lists them. Today that means letting the plugin write sitemap.xml and moving the file in a custom plugin after the build, which every other plugin that modifies the sitemap has to know about.
This PR adds three options:
rx.plugins.SitemapPlugin(
path="sitemap-app.xml",
index_path="sitemap.xml",
index_sitemaps=["https://www.example.com/sitemap-blog.xml"],
)
path(defaultsitemap.xml) is where the sitemap is written below the frontend's public root, which is also its URL path belowfrontend_path.index_path, if set, adds a sitemap index there, listing the app's sitemap (its absolute URL,frontend_urlplusfrontend_pathpluspath) followed byindex_sitemaps, which take absolute URLs or paths resolved againstdeploy_urllike a page'sloc.SitemapPlugin.file_pathnames the generated file, so a plugin that adds to the sitemap throughadd_modify_task(e.g. hreflang alternates) can find it instead of assumingConstants.FILE_PATH.
Paths are normalized without leading or trailing slashes; an empty path, or an index_path naming the sitemap itself, raises a ValueError. With no options the output is unchanged. Docs in docs/api-reference/plugins.md.