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:
parent
53cd55932b
commit
6511115b95
@ -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(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -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"))
|
||||
|
Loading…
Reference in New Issue
Block a user