Skip to content

Commit 334e70b

Browse files
authored
Merge pull request #5 from safstromo/update
Update
2 parents 69d58a5 + fd65794 commit 334e70b

File tree

19 files changed

+4574
-1283
lines changed

19 files changed

+4574
-1283
lines changed

Cargo.lock

Lines changed: 1328 additions & 748 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
[package]
22
name = "rabbitnook"
3-
version = "1.0.3"
4-
edition = "2021"
3+
version = "2.0.0"
4+
edition = "2024"
55

66
[lib]
77
crate-type = ["cdylib", "rlib"]
88

99
[dependencies]
10-
axum = { version = "0.7", optional = true }
10+
axum = { version = "0.8", optional = true }
1111
console_error_panic_hook = "0.1"
12-
leptos = { version = "0.6", features = ["nightly"] }
13-
leptos-use = "0.10"
14-
leptos_axum = { version = "0.6", optional = true }
15-
leptos_meta = { version = "0.6", features = ["nightly"] }
16-
leptos_router = { version = "0.6", features = ["nightly"] }
12+
leptos = { version = "0.8", features = [] }
13+
leptos-use = "0.15"
14+
leptos_axum = { version = "0.8", optional = true }
15+
leptos_meta = { version = "0.8.2", features = ["ssr"] }
16+
leptos_router = { version = "0.8", features = ["nightly"] }
1717
tokio = { version = "1", features = ["rt-multi-thread"], optional = true }
18-
tower = { version = "0.4", optional = true }
19-
tower-http = { version = "0.5", features = ["fs"], optional = true }
18+
tower = { version = "0.5", optional = true }
19+
tower-http = { version = "0.6", features = ["fs"], optional = true }
2020
wasm-bindgen = "=0.2"
21-
thiserror = "1"
21+
thiserror = "2"
2222
tracing = { version = "0.1", optional = true }
2323
http = "1"
2424
lazy_static = "1.4.0"
@@ -29,7 +29,7 @@ version = "0.3"
2929
features = ["Window"]
3030

3131
[features]
32-
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"]
32+
hydrate = ["leptos/hydrate"]
3333
ssr = [
3434
"dep:axum",
3535
"dep:tokio",

public/blog/nix-frame/model.jpg

487 KB
Loading

public/blog/nix-frame/nix_pcb.jpg

1.39 MB
Loading

public/blog/nix-frame/result.jpg

1.94 MB
Loading

public/highlight.min.js

Lines changed: 2497 additions & 0 deletions
Large diffs are not rendered by default.

rust-toolchain.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
[toolchain]
33
channel = "nightly"
44
targets = ["wasm32-unknown-unknown"]
5-

src/app.rs

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,43 @@
1-
use crate::{
2-
components::{
3-
blog::Blog,
4-
links::Links,
5-
name_header::NameHeader,
6-
terminal::{TerminalHistory, TerminalInput},
7-
},
8-
error_template::{AppError, ErrorTemplate},
1+
use crate::components::blogpages::esp32_relay::Esp32Relay;
2+
use crate::components::blogpages::nix_frame_hack::NixFrameHack;
3+
use crate::components::{
4+
blog::Blog,
5+
links::Links,
6+
name_header::NameHeader,
7+
terminal::{TerminalHistory, TerminalInput},
98
};
10-
use leptos::*;
9+
use leptos::prelude::*;
1110
use leptos_meta::*;
11+
use leptos_router::components::{Route, Router, Routes};
1212
use leptos_router::*;
1313

14+
pub fn shell(options: LeptosOptions) -> impl IntoView {
15+
view! {
16+
<!DOCTYPE html>
17+
<html lang="en">
18+
<head>
19+
<meta charset="utf-8" />
20+
<meta name="viewport" content="width=device-width, initial-scale=1" />
21+
<AutoReload options=options.clone() />
22+
<HydrationScripts options />
23+
<MetaTags />
24+
</head>
25+
<body>
26+
<App />
27+
</body>
28+
</html>
29+
}
30+
}
31+
1432
#[component]
1533
pub fn App() -> impl IntoView {
1634
// Provides context that manages stylesheets, titles, meta tags, etc.
1735
provide_meta_context();
1836

1937
view! {
20-
<Stylesheet id="leptos" href="/pkg/rabbitnook.css"/>
21-
<Link rel="preconnect" href="https://fonts.googleapis.com"/>
22-
<Link rel="preconnect" href="https://fonts.gstatic.com"/>
38+
<Stylesheet id="leptos" href="/pkg/rabbitnook.css" />
39+
<Link rel="preconnect" href="https://fonts.googleapis.com" />
40+
<Link rel="preconnect" href="https://fonts.gstatic.com" />
2341
<Link
2442
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap"
2543
rel="stylesheet"
@@ -28,26 +46,21 @@ pub fn App() -> impl IntoView {
2846
rel="stylesheet"
2947
href="//unpkg.com/@catppuccin/highlightjs@0.2.2/css/catppuccin-mocha.css"
3048
/>
31-
<Script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/rust.min.js"/>
32-
<Script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/json.min.js"/>
33-
<Script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/dockerfile.min.js"/>
34-
<Script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/es/languages/bash.min.js"/>
35-
<Script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"/>
3649

3750
// sets the document title
38-
<Title text="RabbitNook"/>
51+
<Title text="RabbitNook" />
3952

40-
// content for this welcome page
41-
<Router fallback=|| {
42-
let mut outside_errors = Errors::default();
43-
outside_errors.insert_with_default_key(AppError::NotFound);
44-
view! { <ErrorTemplate outside_errors/> }.into_view()
45-
}>
53+
<Router>
4654
<main>
47-
<Routes>
48-
<Route path="" view=HomePage/>
49-
<Route path="/blog" view=Blog/>
50-
<Route path="/blog/esp32-relay" view=Blog/>
55+
<Routes fallback=|| "Not Found">
56+
<Route path=path!("") view=HomePage />
57+
<Route path=path!("/blog") view=Blog ssr=SsrMode::Async />
58+
<Route path=path!("/blog/esp32-relay") view=Esp32Relay ssr=SsrMode::Async />
59+
<Route
60+
path=path!("/blog/nix-frame-hack")
61+
view=NixFrameHack
62+
ssr=SsrMode::Async
63+
/>
5164
</Routes>
5265
</main>
5366
</Router>
@@ -57,21 +70,22 @@ pub fn App() -> impl IntoView {
5770
/// Renders the home page of your application.
5871
#[component]
5972
fn HomePage() -> impl IntoView {
60-
let (command_history, set_command_history) = create_signal(vec![]);
61-
let input_element: NodeRef<html::Input> = create_node_ref();
73+
let (command_history, set_command_history) = signal(vec![]);
74+
75+
let input_element = NodeRef::new();
6276

6377
view! {
6478
<div class="flex md:flex-row flex-col min-h-screen w-full bg-base items-center justify-center">
6579
<div class="md:w-1/2 w-5/6 flex flex-col justify-center items-center">
66-
<NameHeader/>
67-
<Links/>
80+
<NameHeader />
81+
<Links />
6882
<div class="w-44 mb-4">
6983
<a href="https://ko-fi.com/safstromo" target="_blank">
70-
<img src="kofi_button_blue.png"/>
84+
<img src="kofi_button_blue.png" />
7185
</a>
7286
</div>
7387

74-
<nav class="my-4 text-white text-2xl font-semibold hover:border-peach border-base border-2 rounded-lg">
88+
<nav class="my-2 text-white text-2xl font-semibold hover:border-peach border-base border-2 rounded-lg">
7589
<a class="mx-1 text-white hover:text-maroon" href="/blog">
7690
Blog
7791
</a>
@@ -84,9 +98,8 @@ fn HomePage() -> impl IntoView {
8498
let _ = input_element.get().expect("Input shoud be there to focus").focus();
8599
}
86100
>
87-
88101
<p class="text-white m-2">"Type 'help' for available commands."</p>
89-
<TerminalHistory command_history=command_history/>
102+
<TerminalHistory command_history=command_history />
90103
<TerminalInput
91104
input_element=input_element
92105
set_command_history=set_command_history

src/components/blog.rs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
1+
use leptos::prelude::*;
12
use leptos::{component, view, IntoView};
3+
use leptos_router::components::A;
24

3-
use crate::components::{blogpages::esp32_relay::Esp32Relay, links::Links};
5+
use crate::components::links::Links;
46

57
#[component]
68
pub fn Blog() -> impl IntoView {
7-
let js_func = r#"
8-
document.addEventListener('DOMContentLoaded', (event) => {
9-
hljs.highlightAll();
10-
});
11-
"#;
12-
139
view! {
14-
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
15-
<script>{js_func}</script>
1610
<div class="flex md:flex-row flex-col min-h-screen w-full bg-base items-center justify-center">
1711
<div class="md:w-2/3 w-5/6 flex flex-col justify-center items-center">
18-
<Esp32Relay/>
19-
<Links/>
12+
13+
<h1 class="my-10 underline">Posts</h1>
14+
<A href="/blog/nix-frame-hack">
15+
<div class="flex flex-col mt-10 border rounded-md w-full">
16+
<h1 class="mx-4 mt-2 text-xl hover:text-maroon">NixPlay frame hacking</h1>
17+
<p class="mx-4 my-2">April 26, 2025</p>
18+
19+
</div>
20+
</A>
21+
<A href="/blog/esp32-relay">
22+
<div class="flex flex-col my-10 border rounded-md w-full">
23+
<h1 class="mx-4 mt-2 text-xl hover:text-maroon">
24+
"Rust ""❤️"" Esp32 remote relay using AWS IoT"
25+
</h1>
26+
<p class="mx-4 my-2">June 20, 2024</p>
27+
</div>
28+
</A>
29+
<Links />
2030
<div class="w-44 mb-6">
2131
<a href="https://ko-fi.com/safstromo" target="_blank">
22-
<img src="kofi_button_blue.png"/>
32+
<img src="../kofi_button_blue.png" />
2333
</a>
2434
</div>
35+
<A href="/">
36+
<p class="underline">Home</p>
37+
</A>
2538
</div>
2639
</div>
2740
}

0 commit comments

Comments
 (0)