~not/mdblog

f3c999c2ae67dc8d24bc3c83d8a1e50d562ad0ee — b123400 10 months ago 71bb657 master
Handle empty title
1 files changed, 5 insertions(+), 1 deletions(-)

M src/post.rs
M src/post.rs => src/post.rs +5 -1
@@ 94,7 94,11 @@ pub async fn list_posts(path: &Path, args: &Args) -> Vec<Post> {
pub async fn read_title(path: &Path) -> Option<String> {
    let extension = path.extension();
    if extension == Some(OsStr::new("html")) || extension == Some(OsStr::new("htm")) {
        return read_html_title(path).await;
        let title = read_html_title(path).await;
        return match title {
            Some(x) if x.len() == 0 => None,
            _ => title,
        };
    }
    let file = tokio::fs::File::open(path).await.ok()?;
    let reader = tokio::io::BufReader::new(file);