get rid of unwrap/expect and do things right
This commit is contained in:
parent
109a1c1e84
commit
bd54b95f1b
1 changed files with 13 additions and 13 deletions
|
@ -2,9 +2,8 @@ use crate::components::article::ArticleData;
|
|||
use leptos::*;
|
||||
use serde::Deserialize;
|
||||
|
||||
// Can this merge with ArticleData somehow?
|
||||
#[derive(Deserialize)]
|
||||
struct TomlData {
|
||||
struct ArticleFrontmatter {
|
||||
content_type: String,
|
||||
title: String,
|
||||
date: String,
|
||||
|
@ -27,12 +26,11 @@ pub async fn slingshot(path: String) -> Result<Vec<ArticleData>, ServerFnError>
|
|||
.expect("Problem processing markdown");
|
||||
let content = html_from_md.content;
|
||||
let _toc = html_from_md.toc;
|
||||
let frontmatter = html_from_md
|
||||
.frontmatter
|
||||
.expect(&format!("error getting frontmatter for {}", &file).to_string());
|
||||
|
||||
let toml: TomlData =
|
||||
toml::from_str(&frontmatter.code_block.unwrap().source).unwrap();
|
||||
if let Some(front_raw) = html_from_md.frontmatter {
|
||||
if let Some(front_code) = front_raw.code_block {
|
||||
let toml: ArticleFrontmatter =
|
||||
toml::from_str(&front_code.source)?;
|
||||
|
||||
articles.push(ArticleData {
|
||||
content_type: toml.content_type,
|
||||
|
@ -44,6 +42,8 @@ pub async fn slingshot(path: String) -> Result<Vec<ArticleData>, ServerFnError>
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Simulate lag
|
||||
use std::thread::sleep;
|
||||
|
|
Loading…
Add table
Reference in a new issue