From d7c7cffa1b0561c4c414573b1b15c5428ae1eafe Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Wed, 15 Mar 2023 20:27:00 -0400 Subject: [PATCH] feat: Create site module --- src/site.rs | 7 ++++++- src/site/page.rs | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/site/page.rs diff --git a/src/site.rs b/src/site.rs index 2f603f5..dbcbc5f 100644 --- a/src/site.rs +++ b/src/site.rs @@ -1,12 +1,17 @@ //! Management of on-disk layout of the source of a site -use self::config::Config; +use std::{collections::HashSet, path::PathBuf}; + +use self::{config::Config, page::Page}; pub mod config; +pub mod page; /// Representation of the on-disk structure of a site #[derive(Debug)] pub struct Site { /// Top level configuration pub config: Config, + /// Non-post static pages + pub pages: HashSet, } diff --git a/src/site/page.rs b/src/site/page.rs new file mode 100644 index 0000000..0a17770 --- /dev/null +++ b/src/site/page.rs @@ -0,0 +1,49 @@ +//! Management of a page + +use std::path::PathBuf; + +use serde::{Deserialize, Serialize}; + +/// Representation of the configuration for a page +#[derive(Serialize, Deserialize, Debug)] +pub struct PageConfig { + /// Title of the page + title: String, + /// Style sheets to apply + stylesheets: Vec, +} + +impl Default for PageConfig { + fn default() -> Self { + Self { + title: "Index".to_string(), + stylesheets: ["default", "index"] + .into_iter() + .map(str::to_string) + .collect(), + } + } +} + +/// Representation of a page +#[derive(Debug)] +pub struct Page { + /// Configuration for the page + pub config: PageConfig, + /// Path to the djot file for the page + /// + /// This can be any file in the appropiate directory with a `md` or `djot` extension, however + /// there can only be one file within the directory + /// + /// This path is relative to the directory of the page + pub file: PathBuf, +} + +impl Default for Page { + fn default() -> Self { + Self { + config: PageConfig::default(), + file: "index.djot".into(), + } + } +}