Chunking the blog posts for the stream.

This commit is contained in:
Tom Alexander
2023-12-17 16:57:37 -05:00
parent fdf84e3d0b
commit c3482cf1e4
6 changed files with 84 additions and 10 deletions

View File

@@ -16,6 +16,8 @@ pub(crate) struct BlogPostPage {
pub(crate) title: Option<String>,
pub(crate) date: Option<String>,
pub(crate) children: Vec<IDocumentElement>,
pub(crate) footnotes: Vec<IRealFootnoteDefinition>,
@@ -60,6 +62,7 @@ impl BlogPostPage {
Ok(BlogPostPage {
path,
title: get_title(&document),
date: get_date(&document),
children,
footnotes,
})
@@ -85,3 +88,14 @@ fn get_title(document: &organic::types::Document<'_>) -> Option<String> {
.last()
.map(|kw| kw.value.to_owned())
}
fn get_date(document: &organic::types::Document<'_>) -> Option<String> {
organic::types::AstNode::from(document)
.iter_all_ast_nodes()
.filter_map(|node| match node {
organic::types::AstNode::Keyword(kw) if kw.key.eq_ignore_ascii_case("date") => Some(kw),
_ => None,
})
.last()
.map(|kw| kw.value.to_owned())
}