Implement a flawed version of RenderBlogStreamEntry::new.

There are some shortcomings in this implementation listed in the comments, but this is the general structure.
This commit is contained in:
Tom Alexander 2023-12-19 10:59:34 -05:00
parent 53cd55932b
commit 6511115b95
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 29 additions and 2 deletions

View File

@ -93,6 +93,33 @@ impl RenderBlogStreamEntry {
output_file: &Path,
original: &BlogPost,
) -> Result<RenderBlogStreamEntry, CustomError> {
todo!()
// TODO: This link is probably wrong.
let link_to_blog_post = get_web_path(
config,
output_directory,
output_file,
output_file.strip_prefix(output_directory)?,
)?;
// TODO: Should I guess an index page instead of erroring out?
let index_page = original
.get_index_page()
.ok_or_else(|| format!("Blog post {} needs an index page.", original.id))?;
let title = index_page.title.clone();
// TODO: Handle footnotes.
let children = index_page
.children
.iter()
.map(|child| RenderDocumentElement::new(config, output_directory, output_file, child))
.collect::<Result<Vec<_>, _>>()?;
Ok(RenderBlogStreamEntry {
title,
self_link: Some(link_to_blog_post),
children,
footnotes: Vec::new(),
})
}
}

View File

@ -103,7 +103,7 @@ impl BlogPost {
}
/// Get the blog post page for index.org
fn get_index_page(&self) -> Option<&BlogPostPage> {
pub(crate) fn get_index_page(&self) -> Option<&BlogPostPage> {
self.pages
.iter()
.find(|page| page.path == Path::new("index.org"))