mirror of
https://github.com/Nutomic/ibis.git
synced 2024-12-26 13:31:24 +00:00
fix
This commit is contained in:
parent
a32bb4bbce
commit
c2c77d8974
4 changed files with 7 additions and 15 deletions
|
@ -27,7 +27,6 @@ use api::api_routes;
|
|||
use assets::file_and_error_handler;
|
||||
use axum::{
|
||||
body::Body,
|
||||
extract::State,
|
||||
http::{HeaderValue, Request},
|
||||
middleware::Next,
|
||||
response::{IntoResponse, Response},
|
||||
|
@ -102,7 +101,6 @@ pub async fn start(config: IbisConfig, override_hostname: Option<SocketAddr>) ->
|
|||
|
||||
let config = data.clone();
|
||||
let app = Router::new()
|
||||
//.leptos_routes(&leptos_options, routes, App)
|
||||
.leptos_routes_with_handler(routes, get(leptos_routes_handler))
|
||||
.fallback(file_and_error_handler)
|
||||
.with_state(leptos_options)
|
||||
|
@ -125,11 +123,7 @@ pub async fn start(config: IbisConfig, override_hostname: Option<SocketAddr>) ->
|
|||
}
|
||||
|
||||
/// Make auth token available in hydrate mode
|
||||
async fn leptos_routes_handler(
|
||||
jar: CookieJar,
|
||||
State(option): State<LeptosOptions>,
|
||||
req: Request<Body>,
|
||||
) -> Response {
|
||||
async fn leptos_routes_handler(jar: CookieJar, req: Request<Body>) -> Response {
|
||||
let handler = leptos_axum::render_app_async_with_context(
|
||||
move || {
|
||||
let cookie = jar.get(AUTH_COOKIE).map(|c| c.value().to_string());
|
||||
|
|
|
@ -33,10 +33,7 @@ use anyhow::anyhow;
|
|||
use reqwest::{Client, RequestBuilder, StatusCode};
|
||||
use send_wrapper::SendWrapper;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
future::Future,
|
||||
sync::{LazyLock},
|
||||
};
|
||||
use std::{future::Future, sync::LazyLock};
|
||||
use url::Url;
|
||||
|
||||
pub static CLIENT: LazyLock<ApiClient> = LazyLock::new(|| ApiClient::new(Client::new(), None));
|
||||
|
|
|
@ -62,11 +62,12 @@ impl<T: Default + Send + Sync> DefaultResource<T> for Resource<T> {
|
|||
|
||||
#[component]
|
||||
pub fn App() -> impl IntoView {
|
||||
// TODO: should Resource::new() but then things break
|
||||
let site_resource = LocalResource::new(|| async move { CLIENT.site().await.unwrap() });
|
||||
provide_context(site_resource);
|
||||
provide_meta_context();
|
||||
|
||||
// TODO: should Resource::new() but then things break
|
||||
let site_resource = Resource::new(|| (), |_| async move { CLIENT.site().await.unwrap() });
|
||||
provide_context(site_resource);
|
||||
|
||||
let darkmode = DarkMode::init();
|
||||
provide_context(darkmode.clone());
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ pub fn Nav() -> impl IntoView {
|
|||
<A href="/article/list">"Articles"</A>
|
||||
</li>
|
||||
<Transition>
|
||||
<Show when=is_logged_in>
|
||||
<Show when=move || is_logged_in()>
|
||||
<li>
|
||||
<A href="/article/create">"Create Article"</A>
|
||||
</li>
|
||||
|
|
Loading…
Reference in a new issue