mirror of
https://github.com/zyllian/webdog.git
synced 2025-05-10 02:26:42 -07:00
add syntax highlighting for code blocks
This commit is contained in:
parent
a8d8096ba6
commit
e3630208fa
8 changed files with 251 additions and 6 deletions
17
src/lib.rs
17
src/lib.rs
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue