From 78ffa6b738031e89e4ac3e0cafbd48e7e5d6969d Mon Sep 17 00:00:00 2001 From: Adam <24621027+adoyle0@users.noreply.github.com> Date: Tue, 16 Jan 2024 12:47:02 -0500 Subject: [PATCH] markdown --- doordesk/Cargo.lock | 16 ++++++++++++++++ doordesk/app/Cargo.toml | 1 + doordesk/app/src/components/article.rs | 2 +- doordesk/app/src/components/slingshot.rs | 15 ++++++++++----- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/doordesk/Cargo.lock b/doordesk/Cargo.lock index 4459389..11bf24f 100644 --- a/doordesk/Cargo.lock +++ b/doordesk/Cargo.lock @@ -86,6 +86,7 @@ dependencies = [ "leptos_axum", "leptos_meta", "leptos_router", + "markdown", "serde", "thiserror", ] @@ -1333,6 +1334,15 @@ dependencies = [ "quote", ] +[[package]] +name = "markdown" +version = "1.0.0-alpha.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0f0025e8c0d89b84d6dc63e859475e40e8e82ab1a08be0a93ad5731513a508" +dependencies = [ + "unicode-id", +] + [[package]] name = "matchit" version = "0.7.3" @@ -2408,6 +2418,12 @@ version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +[[package]] +name = "unicode-id" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1b6def86329695390197b82c1e244a54a131ceb66c996f2088a3876e2ae083f" + [[package]] name = "unicode-ident" version = "1.0.12" diff --git a/doordesk/app/Cargo.toml b/doordesk/app/Cargo.toml index ad03c30..1713d96 100644 --- a/doordesk/app/Cargo.toml +++ b/doordesk/app/Cargo.toml @@ -15,6 +15,7 @@ http.workspace = true cfg-if.workspace = true thiserror.workspace = true serde = "1.0.195" +markdown = "1.0.0-alpha.16" [features] default = [] diff --git a/doordesk/app/src/components/article.rs b/doordesk/app/src/components/article.rs index fe468a6..c4b1b91 100644 --- a/doordesk/app/src/components/article.rs +++ b/doordesk/app/src/components/article.rs @@ -12,7 +12,7 @@ pub fn Article(data: ArticleData) -> impl IntoView {
{&data.date} -
{&data.content}
+
} diff --git a/doordesk/app/src/components/slingshot.rs b/doordesk/app/src/components/slingshot.rs index 53453d6..4d99e1e 100644 --- a/doordesk/app/src/components/slingshot.rs +++ b/doordesk/app/src/components/slingshot.rs @@ -1,9 +1,6 @@ use leptos::*; use serde::{Deserialize, Serialize}; -use std::thread::sleep; -use std::time::Duration; - pub fn fetch(path: &str) -> String { format!("https://dennis.doordesk.net/{path}") } @@ -18,21 +15,29 @@ pub struct ArticleData { #[server(Slingshot)] pub async fn slingshot() -> Result, ServerFnError> { + let md1: String = markdown::to_html("[test](https://lickmysa.cc)"); + let md2: String = markdown::to_html("[test2](https://lickmysa.cc)"); + + let data_vec = vec![ ArticleData { content_type: String::from("Blog"), title: String::from("Test article"), date: String::from("12/21/2022"), - content: String::from("Testicles"), + content: md1, }, ArticleData { content_type: String::from("Blog"), title: String::from("Test article 2"), date: String::from("12/22/2022"), - content: String::from("Testicless"), + content: md2, }, ]; + // Simulate lag + use std::thread::sleep; + use std::time::Duration; sleep(Duration::from_secs(1)); + Ok(data_vec) }