2023-12-19 14:54:12 -05:00
|
|
|
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,
|
2023-12-19 17:51:35 -05:00
|
|
|
|
|
|
|
|
/// An optional string that gets added to IDs in HTML.
|
|
|
|
|
///
|
|
|
|
|
/// This is useful for cases where you may have conflicting HTML
|
|
|
|
|
/// IDs, for example, multiple blog posts with footnotes in a blog
|
|
|
|
|
/// stream.
|
|
|
|
|
pub(crate) id_addition: Option<&'intermediate str>,
|
2023-12-19 14:54:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'intermediate> RenderContext<'intermediate> {
|
|
|
|
|
pub(crate) fn new(
|
|
|
|
|
config: &'intermediate Config,
|
|
|
|
|
output_directory: &'intermediate Path,
|
|
|
|
|
output_file: &'intermediate Path,
|
2023-12-19 17:51:35 -05:00
|
|
|
id_addition: Option<&'intermediate str>,
|
2023-12-19 14:54:12 -05:00
|
|
|
) -> Result<RenderContext<'intermediate>, CustomError> {
|
|
|
|
|
Ok(RenderContext {
|
|
|
|
|
config,
|
|
|
|
|
output_directory,
|
|
|
|
|
output_file,
|
2023-12-19 17:51:35 -05:00
|
|
|
id_addition,
|
2023-12-19 14:54:12 -05:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|