blog_tools/sitemap/
types.rs

1/// Options to configure how the sitemap is generated
2///
3/// `blog-tools` can generate a sitemap for all of the blogs and tags,
4/// but obviously doesn't know about any other pages. However, if you provide
5/// this struct with a String representation of an XML sitemap it will
6/// automatically add those pages into the sitemap for you
7pub struct SitemapOptions {
8    /// The default priority to use for a blog in the sitemap if no priority is
9    /// provided inside the JSON. If this is not explicityly set then the
10    /// default is 0.5
11    pub default_priority: f64,
12    /// Whether to include tag pages in the sitemap. Set this to `true` if your
13    /// website has explicit pages where all the blogs of a certain tag are
14    /// present
15    pub include_tags: bool,
16    /// This represents the location of the blog in the URL. The default is
17    /// `blog`. This would mean the individual blog posts are found at
18    /// `www.example.com/blog/2024-05-12/my-blog`. If you set this parameter to
19    /// `blog-home` then the sitemap would generate
20    /// www.example.com/blog-home/2024-05/12/my-blog`
21    pub blog_root_slug: String,
22    /// This represents the location of the tag index in the URL. The default is
23    /// `blog/tag`, if you set `include_tags` to `true`. If `include_tags` is
24    /// `false` (default behaviour), then this is ignored.
25    /// For example, if you had a tag called `science` then the
26    /// URL would be `www.example.com/blog/tag/science`.
27    pub tag_root_slug: String,
28    /// Optional `String` representation of an XML sitemap. This function will
29    /// automatically merge the records of this sitemap into the sitemap it
30    /// generates. Useful if you have a bunch of pages which are not part of the
31    /// blog that you'd like in the sitemap
32    pub sitemap_base: Option<String>,
33}
34
35impl Default for SitemapOptions {
36    fn default() -> Self {
37        Self {
38            default_priority: 0.5, // TODO: Maybe move this value into a constant?
39            include_tags: false,
40            blog_root_slug: "blog".to_string(), // TODO: Maybe move this value into a constant?
41            tag_root_slug: "blog/tag".to_string(),
42            sitemap_base: None,
43        }
44    }
45}