75 lines
1.7 KiB
Rust
75 lines
1.7 KiB
Rust
|
use dioxus::prelude::*;
|
||
|
|
||
|
use crate::domain::entities::site::{Block, PageContent, Post};
|
||
|
|
||
|
use super::meta;
|
||
|
|
||
|
#[component]
|
||
|
pub fn Page() -> Element {
|
||
|
let page = meta::page();
|
||
|
let info = page.data.info;
|
||
|
|
||
|
rsx! {
|
||
|
h2 { "Page {info.title}" }
|
||
|
match page.data.content {
|
||
|
PageContent::Single { content } => rsx! {
|
||
|
PostElement { post: content }
|
||
|
},
|
||
|
PageContent::Collection { kind: _, collection_id } => {
|
||
|
rsx! {
|
||
|
SuspenseBoundary { fallback: |_context: SuspenseContext| rsx! { "..." },
|
||
|
//Collection { collection_id }
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
#[component]
|
||
|
pub fn Collection(collection_id: String) -> Element {
|
||
|
let site = meta::site();
|
||
|
let posts =
|
||
|
use_server_future(move || get_posts(site.info.domain.clone(), collection_id.clone()))?
|
||
|
.suspend()?;
|
||
|
|
||
|
let result = match &*posts.read() {
|
||
|
Ok(posts) => rsx! {
|
||
|
for post in posts.data.clone() {
|
||
|
PostElement { post }
|
||
|
}
|
||
|
},
|
||
|
Err(err) => {
|
||
|
rsx! {
|
||
|
h1 { "FATAL ERROR: {err}" }
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
result
|
||
|
}*/
|
||
|
|
||
|
#[component]
|
||
|
pub fn PostElement(post: Post) -> Element {
|
||
|
rsx! {
|
||
|
for block in post.blocks {
|
||
|
BlockElement { block }
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[component]
|
||
|
pub fn BlockElement(block: Block) -> Element {
|
||
|
match block {
|
||
|
Block::Text { text } => rsx! {
|
||
|
p { "{text}" }
|
||
|
},
|
||
|
Block::Gallery { images } => rsx! {
|
||
|
for image in images {
|
||
|
img { src: "{image.src}", alt: "{image.caption}" }
|
||
|
}
|
||
|
},
|
||
|
}
|
||
|
}
|