Chunking the blog posts for the stream.
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user