use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize};
use url::Url;
#[derive(Debug, Deserialize, Serialize, Clone, Default)]
pub struct Config {
pub site: SiteConfig,
pub hooks: HooksConfig,
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct SiteConfig {
pub url: Url,
pub authors: Option<Vec<String>>,
pub title: Option<String>,
pub description: Option<String>,
pub email: Option<String>,
pub root: PathBuf,
pub output_path: PathBuf,
pub development: bool,
pub syntax_theme: String,
pub syntax_theme_path: Option<PathBuf>,
pub db_file: PathBuf,
}
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct HooksConfig {
pub post: Vec<PostHook>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PostHook {
pub cmd: String,
pub help: Option<String>,
}
impl Default for SiteConfig {
fn default() -> Self {
Self {
url: Url::parse("http://0.0.0.0:8000/").expect("Invalid default URL?"),
authors: None,
title: None,
description: None,
email: None,
root: Path::new("site/").to_owned(),
output_path: Path::new("public/").to_owned(),
development: false,
syntax_theme: String::from("base16-ocean.dark"),
syntax_theme_path: None,
db_file: Path::new("site.db").to_owned(),
}
}
}