Fixed typo with custom font file, added minor templating to replace content::RawHtml() call, updated README.
This commit is contained in:
parent
b85a03c6fd
commit
a9f0964452
11
Cargo.toml
11
Cargo.toml
@ -8,12 +8,17 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
dioxus = "0.3.2"
|
||||
dioxus-web = "0.3.1"
|
||||
dioxus-ssr = "0.3.0"
|
||||
|
||||
rocket = "=0.5.0-rc.3"
|
||||
log = "0.4.6"
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
dioxus-web = "0.3.1"
|
||||
# WebAssembly Debug
|
||||
wasm-logger = "0.2.0"
|
||||
console_error_panic_hook = "0.1.7"
|
||||
rocket = "=0.5.0-rc.3"
|
||||
wasm-bindgen = "0.2"
|
||||
|
||||
[dependencies.rocket_dyn_templates]
|
||||
version = "=0.1.0-rc.3"
|
||||
features = ["handlebars"]
|
||||
|
17
README.md
17
README.md
@ -1,4 +1,4 @@
|
||||
# Dioxus - [letter.werefox.cafe](https://letter.werefox.cafe)
|
||||
# Dioxus (& Rocket) - [letter.werefox.cafe](https://letter.werefox.cafe)
|
||||
|
||||
> A re-implementation of the Valentine's Day site I made, but using Rust's [Dioxus](https://dioxuslabs.com/) crate and [Rocket](https://rocket.rs/) crate.
|
||||
|
||||
@ -16,9 +16,15 @@ cargo build
|
||||
cargo run
|
||||
```
|
||||
|
||||
### Package this project:
|
||||
|
||||
```
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
## Ignore This Section
|
||||
|
||||
> I need to set things up so you can run the Dioxus dev server wothout launching rocket. I'll figire that out later.
|
||||
> **TODO:** Make subcrates for Dioxus and Rocket, should enable dev server for Dioxus while maintaining overall compatibility.
|
||||
|
||||
(or, I personally use the following since port `8080` is usually being used and I want hot reloading)
|
||||
|
||||
@ -26,12 +32,6 @@ cargo run
|
||||
dioxus serve --hot-reload --port 8234
|
||||
```
|
||||
|
||||
### Package this project:
|
||||
|
||||
```
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
@ -41,4 +41,5 @@ cargo build --release
|
||||
- - utils # save some public function
|
||||
- - data # text files that will be read to for data in the app
|
||||
- - components # save some custom components
|
||||
- - templates # put template files here, right now just using handlebar
|
||||
```
|
||||
|
2
public/styles/tailwind.min.css
vendored
2
public/styles/tailwind.min.css
vendored
File diff suppressed because one or more lines are too long
@ -1,8 +1,8 @@
|
||||
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
@font-face {
|
||||
font-family: 'DejaVuSansMono';
|
||||
src: local('DejaVuSansMono'), url('/fonts/DejaVuSansMono.ttf'), format('ttf');
|
||||
|
||||
@font-face {
|
||||
font-family: "DejaVuSansMono";
|
||||
src: url("/fonts/DejaVuSansMono.ttf");
|
||||
}
|
||||
|
34
src/main.rs
34
src/main.rs
@ -1,28 +1,24 @@
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
|
||||
use dioxus::core::VirtualDom;
|
||||
use rocket::fs::FileServer;
|
||||
use rocket::http::ContentType;
|
||||
use rocket::tokio::fs::File;
|
||||
use std::path::Path;
|
||||
|
||||
// #[get("/<font>")]
|
||||
// async fn fonts(font: &str) -> (ContentType, Option<File>) {
|
||||
// let filename = Path::new("public/fonts/").join(font);
|
||||
// (ContentType::TTF, File::open(&filename).await.ok())
|
||||
// }
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
use rust_letter::web_app;
|
||||
|
||||
#[get("/")]
|
||||
async fn index() -> rocket::response::content::RawHtml<String> {
|
||||
let mut vdom = dioxus::core::VirtualDom::new(rust_letter::web_app::App);
|
||||
async fn index() -> Template {
|
||||
let mut vdom = VirtualDom::new(web_app::App);
|
||||
let _ = vdom.rebuild();
|
||||
let mut output = dioxus_ssr::render(&vdom);
|
||||
output = format!(
|
||||
"<head><link href=/styles/tailwind.min.css rel=stylesheet /></head>{}",
|
||||
output
|
||||
let output = dioxus_ssr::render(&vdom);
|
||||
Template::render(
|
||||
"index",
|
||||
context! {
|
||||
app_title: "A Letter For You!",
|
||||
style_include: "<link href=/styles/tailwind.min.css rel=stylesheet />",
|
||||
test: &output
|
||||
},
|
||||
)
|
||||
.to_string();
|
||||
rocket::response::content::RawHtml(output)
|
||||
}
|
||||
|
||||
#[rocket::main]
|
||||
@ -31,8 +27,8 @@ async fn main() -> Result<(), rocket::Error> {
|
||||
.mount("/images", FileServer::from("public/images"))
|
||||
.mount("/styles", FileServer::from("public/styles"))
|
||||
.mount("/fonts", FileServer::from("public/fonts"))
|
||||
.mount("/", routes![index])
|
||||
.mount("/", routes![index]).attach(Template::fairing())
|
||||
.launch()
|
||||
.await?;
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
|
12
templates/index.html.hbs
Normal file
12
templates/index.html.hbs
Normal file
@ -0,0 +1,12 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>{{app_title}}</title>
|
||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta charset="UTF-8" />
|
||||
{{{style_include}}}
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">{{{test}}}</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user