Create a struct that will combine all the context for converting intermediate objects into the dust render context.
This commit is contained in:
parent
94d9a95967
commit
cb3278aba5
@ -8,6 +8,7 @@ use crate::error::CustomError;
|
||||
use super::raw::RawConfig;
|
||||
|
||||
/// This is the config struct used by most of the code, which is an interpreted version of the RawConfig struct which is the raw disk-representation of the config.
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Config {
|
||||
raw: RawConfig,
|
||||
config_path: PathBuf,
|
||||
|
@ -2,7 +2,7 @@ use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
/// This is the struct for the writer.toml config file that ends up in each site's root directory.
|
||||
#[derive(Deserialize, Serialize)]
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub(crate) struct RawConfig {
|
||||
pub(super) site_title: Option<String>,
|
||||
author: Option<String>,
|
||||
@ -25,7 +25,7 @@ impl Default for RawConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub(crate) struct RawConfigStream {
|
||||
pub(super) entries_per_page: Option<usize>,
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ mod quote_block;
|
||||
mod radio_link;
|
||||
mod radio_target;
|
||||
mod regular_link;
|
||||
mod render_context;
|
||||
mod section;
|
||||
mod special_block;
|
||||
mod src_block;
|
||||
|
27
src/context/render_context.rs
Normal file
27
src/context/render_context.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use std::path::Path;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
|
||||
/// The supporting information used for converting the intermediate representation into the dust context for rendering.
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct RenderContext<'intermediate> {
|
||||
pub(crate) config: &'intermediate Config,
|
||||
// TODO: Perhaps rename to output_root_directory.
|
||||
pub(crate) output_directory: &'intermediate Path,
|
||||
pub(crate) output_file: &'intermediate Path,
|
||||
}
|
||||
|
||||
impl<'intermediate> RenderContext<'intermediate> {
|
||||
pub(crate) fn new(
|
||||
config: &'intermediate Config,
|
||||
output_directory: &'intermediate Path,
|
||||
output_file: &'intermediate Path,
|
||||
) -> Result<RenderContext<'intermediate>, CustomError> {
|
||||
Ok(RenderContext {
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user