feat: Default site value

This commit is contained in:
Nathan McCarty 2023-03-16 14:47:52 -04:00
parent f408a32d64
commit b598b7ad71
Signed by: thatonelutenist
GPG Key ID: D70DA3DD4D1E9F96
3 changed files with 23 additions and 5 deletions

View File

@ -1,6 +1,7 @@
use clap::Args;
use color_eyre::eyre::{bail, ensure, Context, Result};
use tracing::instrument;
use color_eyre::eyre::{bail, Context, Result};
use stranger_site_gen::site::Site;
use tracing::{debug, instrument};
use super::GlobalArgs;
@ -30,6 +31,12 @@ impl InitArgs {
);
}
println!("Initalizing new site in {}", site_dir.to_string_lossy());
// Generate the default site, and change the domain if requested
let mut site = Site::default();
if let Some(domain_name) = self.doman_name {
site.config.domain.domain_name = domain_name;
}
debug!(?site);
todo!()
}
}

View File

@ -1,6 +1,6 @@
//! Management of on-disk layout of the source of a site
use std::{collections::HashSet, path::PathBuf};
use std::{collections::HashMap, path::PathBuf};
use self::{config::Config, page::Page};
@ -13,5 +13,16 @@ pub struct Site {
/// Top level configuration
pub config: Config,
/// Non-post static pages
pub pages: HashSet<PathBuf, Page>,
pub pages: HashMap<PathBuf, Page>,
}
impl Default for Site {
fn default() -> Self {
let mut pages = HashMap::new();
pages.insert("index".into(), Page::default());
Self {
config: Config::default(),
pages,
}
}
}

View File

@ -23,7 +23,7 @@ impl Default for Domain {
/// Top level configuration for a site
///
/// Describes the file located at `site/config.dhall`
#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, Default)]
pub struct Config {
/// Doman name settings
pub domain: Domain,