Add support for unlisted posts.
This commit is contained in:
@@ -48,6 +48,16 @@ pub(crate) struct BlogPostPage {
|
||||
pub(crate) children: Vec<IDocumentElement>,
|
||||
|
||||
pub(crate) footnotes: Vec<IRealFootnoteDefinition>,
|
||||
|
||||
pub(crate) natter_publish: PublishStatus,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub(crate) enum PublishStatus {
|
||||
#[default]
|
||||
Full,
|
||||
Unlisted,
|
||||
Unpublished,
|
||||
}
|
||||
|
||||
intermediate!(
|
||||
@@ -93,6 +103,7 @@ intermediate!(
|
||||
date: get_date(original.document),
|
||||
children,
|
||||
footnotes,
|
||||
natter_publish: get_publish_status(original.document).unwrap_or_default(),
|
||||
})
|
||||
}
|
||||
);
|
||||
@@ -129,3 +140,25 @@ pub(crate) fn get_date(document: &organic::types::Document<'_>) -> Option<String
|
||||
.last()
|
||||
.map(|kw| kw.value.to_owned())
|
||||
}
|
||||
|
||||
pub(crate) fn get_publish_status(document: &organic::types::Document<'_>) -> Option<PublishStatus> {
|
||||
let publish_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("natter_publish") =>
|
||||
{
|
||||
Some(kw)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.last()
|
||||
.map(|kw| kw.value);
|
||||
match publish_string {
|
||||
Some("full") => Some(PublishStatus::Full),
|
||||
Some("unlisted") => Some(PublishStatus::Unlisted),
|
||||
Some("unpublished") => Some(PublishStatus::Unpublished),
|
||||
Some(status) => panic!("Unrecognized publish status: {}", status),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ pub(crate) use babel_call::IBabelCall;
|
||||
pub(crate) use blog_post::get_org_files;
|
||||
pub(crate) use blog_post::BlogPost;
|
||||
pub(crate) use blog_post_page::BlogPostPage;
|
||||
pub(crate) use blog_post_page::PublishStatus;
|
||||
pub(crate) use bold::IBold;
|
||||
pub(crate) use center_block::ICenterBlock;
|
||||
pub(crate) use citation::ICitation;
|
||||
|
||||
Reference in New Issue
Block a user