oranda/config/components/
changelog.rs

1use crate::config::{ApplyLayer, ApplyValExt};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5/// Config for tweaking the changelog page generation
6#[derive(Debug, Clone)]
7pub struct ChangelogConfig {
8    /// Whether to attempt to read from the local changelog file
9    pub read_changelog_file: bool,
10    /// Whether to generate a RSS file
11    pub rss_feed: bool,
12}
13
14/// The config for generating a separate changelog page
15#[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]
16pub struct ChangelogLayer {
17    /// Whether we factor in the local `CHANGELOG.md` file, attempt to parse
18    /// it, and try and match version headings to release versions that we
19    /// detect.
20    pub read_changelog_file: Option<bool>,
21    /// Whether to generate a RSS file under `changelog.rss`.
22    pub rss_feed: Option<bool>,
23}
24
25impl Default for ChangelogConfig {
26    fn default() -> Self {
27        ChangelogConfig {
28            read_changelog_file: true,
29            rss_feed: true,
30        }
31    }
32}
33
34impl ApplyLayer for ChangelogConfig {
35    type Layer = ChangelogLayer;
36    fn apply_layer(&mut self, layer: Self::Layer) {
37        // This is intentionally written slightly cumbersome to make you update this
38        let ChangelogLayer {
39            read_changelog_file,
40            rss_feed,
41        } = layer;
42        self.read_changelog_file.apply_val(read_changelog_file);
43        self.rss_feed.apply_val(rss_feed);
44    }
45}