feat: Default site value
This commit is contained in:
parent
f408a32d64
commit
b598b7ad71
|
@ -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!()
|
||||
}
|
||||
}
|
||||
|
|
15
src/site.rs
15
src/site.rs
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue