Added Markdown file conversion. Changed some Cargo params to keep rust-analyzer from freaking out. Updated build.rs to not panic when 'npx' isn't in the path.

This commit is contained in:
Ada Werefox 2023-04-06 19:12:04 -05:00
parent cd13cbbc1e
commit 686e591f21
8 changed files with 45 additions and 26 deletions

View File

@ -10,9 +10,15 @@ members = [
"rust-letter-be",
]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rust-letter-be = { path = "./rust-letter-be" }
[workspace.dependencies]
rocket = "=0.5.0-rc.3"
tokio = "1.27.0"
dioxus = "0.3.2"
markdown = "1.0.0-alpha.7"
dioxus-ssr = "0.3.0"
log = "0.4.6"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rust-letter-be = { path = "./rust-letter-be" }
rocket = { workspace = true }

16
data/poem.md Normal file
View File

@ -0,0 +1,16 @@
You are important. I wrote a small poem I hope will help you today.\
It's not very long, but I'm doing my best, and so are you.
You are the moon, you are the stars\
Im glad you're here, whomever you are.\
We've been through much; in this life it's true,\
But in the end, you will come through.
Much like life, this poem is short\
It doesn't always rhyme, or have a nice beat;\
It might seem wrong, or incomplete;\
It might go on, or so it seems;\
It might feel like you're in a dream.
That's not the point, I know in my heart\
I'm glad you're here, whomever you are.

View File

@ -6,13 +6,13 @@ edition = "2021"
[dependencies]
rust-letter-fe = { path = "../rust-letter-fe" }
dioxus-ssr = "0.3.0"
log = "0.4.6"
dioxus-ssr = { workspace = true }
log = { workspace = true }
# If you're unsure about why we're depending on a release candidate,
# check the Rocket documentation:
# https://rocket.rs/v0.5-rc/guide/upgrading/
rocket = "=0.5.0-rc.3"
rocket = { workspace = true }
# Needed to enable handlebar template support
[dependencies.rocket_dyn_templates]

View File

@ -5,10 +5,8 @@ authors = ["Ada Werefox <ada.werefox@tutanota.com>"]
edition = "2021"
[dependencies]
dioxus = "0.3.2"
# Only need these when we're using this crate as a dev server
[target.'cfg(target_family = "wasm")'.dependencies]
dioxus = { workspace = true }
markdown = { workspace = true }
dioxus-web = "0.3.1"
dioxus-autofmt = "0.3.0"
# WebAssembly Debug

View File

@ -5,5 +5,11 @@ fn main() {
.split(" "),
);
tailwind.env("NODE_ENV", "production");
tailwind.spawn().unwrap();
match tailwind.spawn() {
Ok(_) => (),
Err(_) => {
print!("Didn't find npx in the path, can't compile CSS. Is Node installed?");
()
}
}
}

View File

@ -1,5 +1,5 @@
//! # Rust Letter Frontend
//!
//!
//! Rendering functions for the site using [Dioxus](https://dioxuslabs.com/).
#![allow(non_snake_case)]
@ -44,7 +44,8 @@ pub mod web_app {
}
fn MakePoem(cx: Scope) -> Element {
let poem = include_str!("../../data/poem.txt").split("\n\n");
let poem_str = include_str!("../../data/poem.md");
let poem = markdown::to_html(poem_str);
cx.render(rsx!(
div {
@ -61,15 +62,7 @@ pub mod web_app {
},
div {
class: "font-nerd flex flex-col space-y-4 mx-4 py-4",
poem.map(|phrase| rsx!(
div {
phrase.lines().map(|line| rsx!(
p {
line
}
))
}
))
dangerous_inner_html: "{poem}",
}
}
}

View File

@ -1,6 +1,6 @@
use rust_letter_fe::web_app;
use dioxus_web;
use console_error_panic_hook;
use dioxus_web::{self, Config};
use rust_letter_fe::web_app::{self, VirtualDom};
use wasm_logger;
fn main() {

View File

@ -4,4 +4,4 @@ use rust_letter_be::web_app_backend;
async fn main() -> Result<(), rocket::Error> {
let _rocket = web_app_backend::build_rocket().await.launch().await;
Ok(())
}
}