···14jacquard-axum = { workspace = true, optional = true }
15weaver-api = { path = "../weaver-api", features = ["streaming"] }
16markdown-weaver = { workspace = true }
017moka = { version = "0.12", features = ["future"], optional = true }
18mini-moka = { version = "0.10" }
19dioxus-primitives = { git = "https://github.com/DioxusLabs/components", version = "0.0.1", default-features = false }
02021[features]
22default = ["web"]
···27# The feature that are only required for the mobile = ["dioxus/mobile"] build target should be optional and only enabled in the mobile = ["dioxus/mobile"] feature
28mobile = ["dioxus/mobile"]
29# The feature that are only required for the server = ["dioxus/server"] build target should be optional and only enabled in the server = ["dioxus/server"] feature
30-server = ["dioxus/server", "dep:jacquard-axum", "dep:moka"]
···14jacquard-axum = { workspace = true, optional = true }
15weaver-api = { path = "../weaver-api", features = ["streaming"] }
16markdown-weaver = { workspace = true }
17+weaver-renderer = { path = "../weaver-renderer" }
18moka = { version = "0.12", features = ["future"], optional = true }
19mini-moka = { version = "0.10" }
20dioxus-primitives = { git = "https://github.com/DioxusLabs/components", version = "0.0.1", default-features = false }
21+axum = {version = "0.8.6", optional = true}
2223[features]
24default = ["web"]
···29# The feature that are only required for the mobile = ["dioxus/mobile"] build target should be optional and only enabled in the mobile = ["dioxus/mobile"] feature
30mobile = ["dioxus/mobile"]
31# The feature that are only required for the server = ["dioxus/server"] build target should be optional and only enabled in the server = ["dioxus/server"] feature
32+server = ["dioxus/server", "dep:jacquard-axum", "dep:moka", "dep:axum"]
···2//! They can be used to defined common UI elements like buttons, forms, and modals. In this template, we define a Hero
3//! component and an Echo component for fullstack apps to be used in our app.
45-mod cssblob;
067mod entry;
8pub use entry::{Entry, EntryCard};
···2//! They can be used to defined common UI elements like buttons, forms, and modals. In this template, we define a Hero
3//! component and an Echo component for fullstack apps to be used in our app.
45+mod css;
6+pub use css::NotebookCss;
78mod entry;
9pub use entry::{Entry, EntryCard};
···8use std::sync::Arc;
9use views::{Home, Navbar, Notebook, NotebookIndex, NotebookPage};
10011/// Define a components module that contains all shared components for our app.
12mod components;
13mod fetch;
···53 // Run `serve()` on the server only
54 #[cfg(feature = "server")]
55 dioxus::serve(|| async move {
056 // Create a new router for our app using the `router` function
57- let mut router = dioxus::server::router(App);
0000000000000005859 // .. customize the router, adding layers and new routes
60
···8use std::sync::Arc;
9use views::{Home, Navbar, Notebook, NotebookIndex, NotebookPage};
1011+mod blobcache;
12/// Define a components module that contains all shared components for our app.
13mod components;
14mod fetch;
···54 // Run `serve()` on the server only
55 #[cfg(feature = "server")]
56 dioxus::serve(|| async move {
57+ use axum::{extract::Request, middleware, middleware::Next};
58 // Create a new router for our app using the `router` function
59+ let mut router = dioxus::server::router(App).layer(middleware::from_fn(
60+ |mut req: Request, next: Next| async move {
61+ // Attach some extra state to the request
62+63+ use crate::fetch::CachedFetcher;
64+ use std::convert::Infallible;
65+ use std::sync::Arc;
66+ req.extensions_mut()
67+ .insert(Arc::new(CachedFetcher::new(Arc::new(
68+ BasicClient::unauthenticated(),
69+ ))));
70+71+ // And then return the response with `next.run()
72+ Ok::<_, Infallible>(next.run(req).await)
73+ },
74+ ));
7576 // .. customize the router, adding layers and new routes
77
+4-10
crates/weaver-server/src/views/notebook.rs
···1-use crate::{fetch, Route};
2use dioxus::prelude::*;
3use jacquard::{
4- client::BasicClient,
5- smol_str::SmolStr,
6- types::{ident::AtIdentifier, tid::Tid},
7- CowStr,
8};
9-use std::sync::Arc;
10-11-const BLOG_CSS: Asset = asset!("/assets/styling/blog.css");
1213/// The Blog page component that will be rendered when the current route is `[Route::Blog]`
14///
···16/// re-run and the rendered HTML will be updated.
17#[component]
18pub fn Notebook(ident: AtIdentifier<'static>, book_title: SmolStr) -> Element {
19- let fetcher = use_context::<fetch::CachedFetcher>();
20 rsx! {
21- document::Link { rel: "stylesheet", href: BLOG_CSS }
22 Outlet::<Route> {}
23 }
24}
···1+use crate::{components::NotebookCss, fetch, Route};
2use dioxus::prelude::*;
3use jacquard::{
4+ smol_str::{SmolStr, ToSmolStr},
5+ types::ident::AtIdentifier,
006};
00078/// The Blog page component that will be rendered when the current route is `[Route::Blog]`
9///
···11/// re-run and the rendered HTML will be updated.
12#[component]
13pub fn Notebook(ident: AtIdentifier<'static>, book_title: SmolStr) -> Element {
014 rsx! {
15+ NotebookCss { ident: ident.to_smolstr(), notebook: book_title }
16 Outlet::<Route> {}
17 }
18}
-4
crates/weaver-server/src/views/notebookpage.rs
···2use dioxus::prelude::*;
3use jacquard::types::tid::Tid;
45-const BLOG_CSS: Asset = asset!("/assets/styling/blog.css");
6-7/// The Blog page component that will be rendered when the current route is `[Route::Blog]`
8///
9/// The component takes a `id` prop of type `i32` from the route enum. Whenever the id changes, the component function will be
···11#[component]
12pub fn NotebookPage(id: Tid, children: Element) -> Element {
13 rsx! {
14- document::Link { rel: "stylesheet", href: BLOG_CSS }
15-16 div {
17 id: "blog",
18
···2use dioxus::prelude::*;
3use jacquard::types::tid::Tid;
4005/// The Blog page component that will be rendered when the current route is `[Route::Blog]`
6///
7/// The component takes a `id` prop of type `i32` from the route enum. Whenever the id changes, the component function will be
···9#[component]
10pub fn NotebookPage(id: Tid, children: Element) -> Element {
11 rsx! {
0012 div {
13 id: "blog",
14