add syntax highlighting for code blocks

This commit is contained in:
zyl 2024-11-07 14:56:13 -08:00
parent a8d8096ba6
commit e3630208fa
Signed by: zyl
SSH key fingerprint: SHA256:uxxbSXbdroP/OnKBGnEDk5q7EKB2razvstC/KmzdXXs
8 changed files with 251 additions and 6 deletions

View file

@ -43,6 +43,12 @@ pub struct SiteConfig {
pub sass_styles: Vec<PathBuf>,
/// URL to the CDN used for the site's images.
pub cdn_url: Url,
/// The theme to use for the site's code blocks.
/// TODO: dark/light themes
/// TODO: export themes as CSS instead of styling HTML directly
/// TODO: allow loading user themes
pub code_theme: String,
/// List of resources the site should build.
pub resources: HashMap<String, ResourceBuilderConfig>,
}
@ -52,6 +58,17 @@ impl SiteConfig {
pub fn cdn_url(&self, file: &str) -> eyre::Result<Url> {
Ok(self.cdn_url.join(file)?)
}
/// Checks the site config for errors.
pub fn check(&self, builder: &SiteBuilder) -> eyre::Result<()> {
builder
.theme_set
.themes
.contains_key(&self.code_theme)
.then_some(())
.ok_or_else(|| eyre::eyre!("missing code theme: {}", self.code_theme))?;
Ok(())
}
}
/// Struct for the front matter in templates. (nothing here yet)