Store the path to the original source file in the blog post object.

This commit is contained in:
Tom Alexander 2025-02-07 21:08:06 -05:00
parent 463be34302
commit 5cac44c625
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 28 additions and 4 deletions

View File

@ -163,7 +163,7 @@ async fn load_pages(config: &Config) -> Result<Vec<IPage>, CustomError> {
ret.push(
IPage::new(
intermediate_context,
PageInput::new(relative_to_pages_dir_path, parsed_document),
PageInput::new(relative_to_pages_dir_path, real_path, parsed_document),
)
.await?,
);

View File

@ -76,7 +76,11 @@ impl BlogPost {
ret.push(
BlogPostPage::new(
intermediate_context,
BlogPostPageInput::new(relative_to_post_dir_path, parsed_document),
BlogPostPageInput::new(
relative_to_post_dir_path,
real_path,
parsed_document,
),
)
.await?,
);

View File

@ -11,17 +11,23 @@ use super::ISection;
#[derive(Debug)]
pub(crate) struct BlogPostPageInput<'b, 'parse> {
/// Relative path from the root of the blog post.
path: PathBuf,
/// The path to the .org source for the file.
src: PathBuf,
document: &'b organic::types::Document<'parse>,
}
impl<'b, 'parse> BlogPostPageInput<'b, 'parse> {
pub(crate) fn new<P: Into<PathBuf>>(
pub(crate) fn new<P: Into<PathBuf>, S: Into<PathBuf>>(
path: P,
src: S,
document: &'b organic::types::Document<'parse>,
) -> BlogPostPageInput<'b, 'parse> {
BlogPostPageInput {
path: path.into(),
src: src.into(),
document,
}
}
@ -32,6 +38,9 @@ pub(crate) struct BlogPostPage {
/// Relative path from the root of the blog post.
pub(crate) path: PathBuf,
/// The path to the .org source for the file.
pub(crate) src: PathBuf,
pub(crate) title: Option<String>,
pub(crate) date: Option<String>,
@ -79,6 +88,7 @@ intermediate!(
Ok(BlogPostPage {
path: original.path,
src: original.src,
title: get_title(original.document),
date: get_date(original.document),
children,

View File

@ -13,6 +13,9 @@ pub(crate) struct IPage {
/// Relative path from the root of the pages directory.
pub(crate) path: PathBuf,
/// The path to the .org source for the file.
pub(crate) src: PathBuf,
pub(crate) title: Option<String>,
#[allow(dead_code)]
@ -61,6 +64,7 @@ intermediate!(
Ok(IPage {
path: original.path,
src: original.src,
title: get_title(original.document),
date: get_date(original.document),
children,
@ -80,17 +84,23 @@ impl IPage {
#[derive(Debug)]
pub(crate) struct PageInput<'b, 'parse> {
/// Relative path from the root of the page.
path: PathBuf,
/// The path to the .org source for the file.
src: PathBuf,
document: &'b organic::types::Document<'parse>,
}
impl<'b, 'parse> PageInput<'b, 'parse> {
pub(crate) fn new<P: Into<PathBuf>>(
pub(crate) fn new<P: Into<PathBuf>, S: Into<PathBuf>>(
path: P,
src: S,
document: &'b organic::types::Document<'parse>,
) -> PageInput<'b, 'parse> {
PageInput {
path: path.into(),
src: src.into(),
document,
}
}