use std::collections::HashMap;
use leptos::prelude::*;
use leptos::Params;
use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title};
use leptos_router::hooks::use_params;
use leptos_router::params::Params;
use leptos_router::{
components::{ParentRoute, Route, Router, Routes},
path,
};
use super::editor::WikiEditor;
use super::renderer::WikiPage;
use crate::components::layout::Layout;
use crate::data::Namespace;
use crate::data::Page;
use crate::data::PageUuid;
pub fn shell(options: LeptosOptions) -> impl IntoView {
view! {
}
}
#[component]
pub fn App() -> impl IntoView {
// Provides context that manages stylesheets, titles, meta tags, etc.
provide_meta_context();
view! {
// injects a stylesheet into the document
// id=leptos means cargo-leptos will hot-reload this stylesheet
// sets the document title
// content for this welcome page
}
}
#[derive(Params, PartialEq)]
struct PageParams {
path: Option,
}
#[server]
async fn get_namespace() -> Result {
use crate::data::StormscribeData;
Ok(StormscribeData::get_namespace())
}
#[server]
async fn get_pages() -> Result, ServerFnError> {
use crate::data::StormscribeData;
Ok(StormscribeData::get_pages())
}
// Renders a page
#[component]
fn PageRender() -> impl IntoView {
let params = use_params::();
let page_path = params
.read()
.as_ref()
.ok()
.map(|params| params.path.clone().unwrap_or("Unknown path".to_string()))
.unwrap_or("Could not read params".to_string());
let namespace = Resource::new(move || {}, |_| get_namespace());
let page_resource = Resource::new(move || {}, |_| get_pages());
view! {
"Loading..." }
>
{move || Suspend::new(async move {
let name_data = namespace.await;
let page_data = page_resource.await;
match (name_data, page_data) {
(Ok(names), Ok(pages)) => view! {
{format!("{names:#?}")}
{format!("{pages:#?}")}
}.into_any(),
_ => view! {Error
}.into_any(),
}
})}
}
.into_any()
}
// Renders a page
#[component]
fn PageEdit() -> impl IntoView {
let params = use_params::();
let page_path = params
.read()
.as_ref()
.ok()
.map(|params| params.path.clone().unwrap_or("Unknown path".to_string()))
.unwrap_or("Could not read params".to_string());
view! {
}
}