feat: Create site module
This commit is contained in:
parent
68ccc95345
commit
d7c7cffa1b
|
@ -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<PathBuf, Page>,
|
||||
}
|
||||
|
|
|
@ -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<String>,
|
||||
}
|
||||
|
||||
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(),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue