Skip to content

Commit

Permalink
fix: meta data
Browse files Browse the repository at this point in the history
  • Loading branch information
dancixx committed Aug 31, 2024
1 parent 8d89c8b commit 258dc6b
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions src/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,24 @@ pub fn Component() -> impl IntoView {

view! {
<Suspense fallback=|| ()>
<Title text=post.get().unwrap_or_default().title.to_string() />
<Show when=move || post.get().is_some() fallback=|| view! { <></> }>
<Meta
name="description"
content=post.get().unwrap_or_default().summary.to_string()
/>
<Meta
property="og:title"
content=post.get().unwrap_or_default().title.to_string()
/>
<Meta
property="og:description"
content=post.get().unwrap_or_default().summary.to_string()
/>
</Show>
<Meta property="og:type" content="article" />
<Meta property="og:url" content=format!("https://rust-dd.com/post/{}", slug()) />
<Meta property="og:image" content="https://static.rust-dd.com/rust-dd.png" />
{post
.get()
.unwrap_or_default()
.tags
.into_iter()
.map(|tag| {
view! { <Meta name="keywords" content=tag.to_string() /> }
})
.collect::<Vec<_>>()}
{move || {
post.with(|post| {
let post = post.clone().unwrap_or_default();
view! {
<Title text=post.title.to_string() />
<Meta name="description" content=post.summary.to_string() />
<Meta property="og:title" content=post.title.to_string() />
<Meta property="og:description" content=post.summary.to_string() />
{post
.tags
.into_iter()
.map(|tag| {
view! { <Meta name="keywords" content=tag.to_string() /> }
})
.collect::<Vec<_>>()}
<article>
<div class="flex flex-col gap-4 mx-auto max-w-3xl">
<p class="text-4xl font-semibold">{post.title.clone()}</p>
Expand Down

0 comments on commit 258dc6b

Please sign in to comment.