Add publish option (#28)
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending
This commit is contained in:
parent
bc73c88562
commit
49392f5ca5
2 changed files with 23 additions and 18 deletions
|
@ -14,6 +14,7 @@ pub struct FileMetadata {
|
|||
pub link: Option<String>,
|
||||
pub date: Option<Date>,
|
||||
pub description: Option<String>,
|
||||
pub publish: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Content)]
|
||||
|
|
|
@ -106,7 +106,7 @@ fn get_posts(location: &str) -> Vec<Post> {
|
|||
|
||||
entries
|
||||
.iter()
|
||||
.map(|f| {
|
||||
.filter_map(|f| {
|
||||
let _filename = f.file_name();
|
||||
let filename = _filename.to_string_lossy();
|
||||
let file_without_ext = filename.split_at(filename.len() - 3).0;
|
||||
|
@ -132,7 +132,8 @@ fn get_posts(location: &str) -> Vec<Post> {
|
|||
},
|
||||
};
|
||||
|
||||
Post {
|
||||
if let Some(true) = file_metadata.publish {
|
||||
Some(Post {
|
||||
url: file_without_ext.into(),
|
||||
title: file_metadata.title.unwrap(),
|
||||
date: file_metadata.date.unwrap_or({
|
||||
|
@ -150,6 +151,9 @@ fn get_posts(location: &str) -> Vec<Post> {
|
|||
}),
|
||||
desc: file_metadata.description,
|
||||
content: None,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect::<Vec<Post>>()
|
||||
|
|
Loading…
Reference in a new issue