Something went wrong. Try again.
Minimalist static .md → .html site generator. Declarative and highly customizable. Built with personal sites and the small web in mind! uteri.klastriz.com
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758//! Built-in themes.//!//! A theme is a palette plus the shared layout stylesheet. Templates are the//! same for every theme; a project `style.css` or `templates/` directory still//! wins over the embedded defaults.
/// One built-in theme.#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]pub enum Theme { #[default] UteriNight, UteriDay,}
impl Theme { /// Parse a `theme` value from `site.conf`. pub fn parse(value: &str) -> Option<Self> { match value { "uteri-night" => Some(Theme::UteriNight), "uteri-day" => Some(Theme::UteriDay), _ => None, } }
/// Shared layout plus this theme's palette. pub fn style(self) -> String { let palette = match self { Theme::UteriNight => include_str!("../assets/themes/uteri-night.css"), Theme::UteriDay => include_str!("../assets/themes/uteri-day.css"), }; format!("{}\n{}", include_str!("../assets/theme.css"), palette) }}
#[cfg(test)]mod tests { use super::*;
#[test] fn parses_both_themes() { assert_eq!(Theme::parse("uteri-night"), Some(Theme::UteriNight)); assert_eq!(Theme::parse("uteri-day"), Some(Theme::UteriDay)); assert_eq!(Theme::parse("nope"), None); }
#[test] fn styles_include_the_palette_and_layout() { let night = Theme::UteriNight.style(); assert!(night.contains("--bg: #120a0e")); assert!(night.contains("color-scheme: dark")); assert!(night.contains(".listing"));
let day = Theme::UteriDay.style(); assert!(day.contains("--bg: #faf0f3")); assert!(day.contains("color-scheme: light")); }}