add new method to SiteConfig

This commit is contained in:
zyl 2024-11-07 16:44:45 -08:00
parent 92687016ed
commit 790f25b829
Signed by: zyl
SSH key fingerprint: SHA256:uxxbSXbdroP/OnKBGnEDk5q7EKB2razvstC/KmzdXXs

View file

@ -53,6 +53,21 @@ pub struct SiteConfig {
}
impl SiteConfig {
/// Creates a new site config from the given title.
pub fn new(title: String) -> Self {
let url: Url = "/".parse().expect("should never fail");
Self {
base_url: url.clone(),
title,
description: Default::default(),
build: None,
sass_styles: vec!["index.scss".into()],
cdn_url: url,
code_theme: "base16-ocean.dark".to_string(),
resources: Default::default(),
}
}
/// Gets a CDN url from the given file name.
pub fn cdn_url(&self, file: &str) -> eyre::Result<Url> {
Ok(self.cdn_url.join(file)?)