Finding the index page.

This commit is contained in:
Tom Alexander 2023-12-17 15:45:50 -05:00
parent 0a4376dfb8
commit fdf84e3d0b
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 28 additions and 0 deletions

View File

@ -99,6 +99,10 @@ impl SiteRenderer {
// Steps: for each group, create a RenderBlogStream
//
// Steps: pass each RenderBlogStream to dust as the context to render index.html and any additional stream pages.
for blog_post in &self.blog_posts {
println!("{:?}", blog_post.get_date()?);
}
Ok(())
}

View File

@ -77,6 +77,30 @@ impl BlogPost {
}
inner(root_dir.as_ref(), post_dir.as_ref()).await
}
/// Get the date for a blog post.
///
/// The date is set by the "#+date" export setting. This will
/// first attempt to read the date from an index.org if such a
/// file exists. If that file does not exist or that file does not
/// contain a date export setting, then this will iterate through
/// all the pages under the blog post looking for any page that
/// contains a date export setting. It will return the first date
/// found.
pub(crate) fn get_date(&self) -> Result<(), CustomError> {
if let Some(index_page) = self.get_index_page()? {
println!("{:?}", index_page);
}
Ok(())
}
/// Get the blog post page for index.org
fn get_index_page(&self) -> Result<Option<&BlogPostPage>, CustomError> {
Ok(self
.pages
.iter()
.find(|page| page.path == Path::new("index.org")))
}
}
async fn read_file(path: PathBuf) -> std::io::Result<(PathBuf, String)> {