diff --git a/src/command/build/render.rs b/src/command/build/render.rs index c57a132..05e130a 100644 --- a/src/command/build/render.rs +++ b/src/command/build/render.rs @@ -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(()) } diff --git a/src/intermediate/blog_post.rs b/src/intermediate/blog_post.rs index 4b58d8e..245c0aa 100644 --- a/src/intermediate/blog_post.rs +++ b/src/intermediate/blog_post.rs @@ -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, CustomError> { + Ok(self + .pages + .iter() + .find(|page| page.path == Path::new("index.org"))) + } } async fn read_file(path: PathBuf) -> std::io::Result<(PathBuf, String)> {