Use the deep path as the post id.
This commit is contained in:
@@ -20,14 +20,17 @@ pub(crate) struct BlogPost {
|
||||
}
|
||||
|
||||
impl BlogPost {
|
||||
pub(crate) async fn load_blog_post<P: AsRef<Path>, R: AsRef<Path>>(
|
||||
pub(crate) async fn load_blog_post<P: AsRef<Path>, R: AsRef<Path>, S: AsRef<Path>>(
|
||||
root_dir: R,
|
||||
posts_dir: S,
|
||||
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.");
|
||||
async fn inner(
|
||||
_root_dir: &Path,
|
||||
posts_dir: &Path,
|
||||
post_dir: &Path,
|
||||
) -> Result<BlogPost, CustomError> {
|
||||
let post_id = post_dir.strip_prefix(posts_dir)?.as_os_str();
|
||||
|
||||
let org_files = {
|
||||
let mut ret = Vec::new();
|
||||
@@ -80,7 +83,7 @@ impl BlogPost {
|
||||
pages,
|
||||
})
|
||||
}
|
||||
inner(root_dir.as_ref(), post_dir.as_ref()).await
|
||||
inner(root_dir.as_ref(), posts_dir.as_ref(), post_dir.as_ref()).await
|
||||
}
|
||||
|
||||
/// Get the date for a blog post.
|
||||
|
||||
Reference in New Issue
Block a user