Setting the post id based on the folder name.
This commit is contained in:
@@ -17,6 +17,10 @@ impl BlogPost {
|
||||
post_dir: P,
|
||||
) -> Result<BlogPost, CustomError> {
|
||||
async fn inner(root_dir: &Path, post_dir: &Path) -> Result<BlogPost, CustomError> {
|
||||
let post_id = post_dir
|
||||
.file_name()
|
||||
.expect("The post directory should have a name.");
|
||||
|
||||
let org_files = {
|
||||
let mut ret = Vec::new();
|
||||
let org_files_iter = get_org_files(post_dir)?;
|
||||
@@ -36,7 +40,7 @@ impl BlogPost {
|
||||
};
|
||||
|
||||
Ok(BlogPost {
|
||||
id: "foo".to_owned(),
|
||||
id: post_id.to_string_lossy().into_owned(),
|
||||
})
|
||||
}
|
||||
inner(root_dir.as_ref(), post_dir.as_ref()).await
|
||||
|
||||
Reference in New Issue
Block a user