Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/components/blog_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ pub fn BlogContent(
}

#[component]
#[must_use]
#[allow(clippy::needless_pass_by_value, clippy::implicit_hasher)]
pub fn ArticleHeader(
#[prop()] title: String,
#[prop()] github_user: Option<String>,
Expand Down Expand Up @@ -183,14 +185,14 @@ pub fn ArticleHeader(
})
.collect::<Vec<_>>()}
<div class="flex flex-row flex-wrap items-center gap-2">
{if !social.is_empty() {
{if social.is_empty() {
view! { <></> }
} else {
view! {
<>
<hr class="h-[0.875rem] w-px bg-gray-700 border-0" />
</>
}
} else {
view! { <></> }
}}
{social
.iter()
Expand Down
3 changes: 2 additions & 1 deletion src/components/button_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ use leptos::{component, view, Children, IntoView};
use std::collections::HashMap;

#[component]
#[must_use]
pub fn ButtonLink(
href: &'static str,
#[prop(default = "primary")] color: &'static str,
#[prop(default = "normal")] size: &'static str,
#[prop(default = "drop")] shadow: &'static str,
#[prop(into, optional)] class: String,
#[prop(into, optional)] class: &'static str,
children: Children,
) -> impl IntoView {
let colors = HashMap::from([
Expand Down
4 changes: 4 additions & 0 deletions src/components/card_article.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{
};
use leptos::{component, view, CollectView, IntoView};

#[must_use]
#[component]
pub fn CardArticle(article: Article, is_home: bool) -> impl IntoView {
let article_link = get_link(&article, is_home);
Expand Down Expand Up @@ -67,6 +68,7 @@ fn get_description(article: &Article) -> String {
}
}

#[must_use]
#[component]
pub fn TagsList(tags: Option<Vec<String>>) -> impl IntoView {
let tags = tags.unwrap_or_default();
Expand All @@ -79,6 +81,8 @@ pub fn TagsList(tags: Option<Vec<String>>) -> impl IntoView {
}

#[component]
#[allow(clippy::needless_pass_by_value)]
#[must_use]
pub fn TagButton(tag: String) -> impl IntoView {
let tag = tag.to_lowercase().replace(' ', "-");

Expand Down
8 changes: 4 additions & 4 deletions src/components/esta_semana_en_rust/blog_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn BlogContent(#[prop()] article: Article) -> impl IntoView {
</h1>
<div class="flex flex-col">
<div class="flex flex-row gap-4 text-sm items-center">
{if !article.has_author() {
{if article.has_author() {
view! {
<>
<h5>{article.author}</h5>
Expand All @@ -51,14 +51,14 @@ pub fn BlogContent(#[prop()] article: Article) -> impl IntoView {
} else {
view! { <></> }
}}
{if !social.is_empty() {
{if social.is_empty() {
view! { <></> }
} else {
view! {
<>
<hr class="h-[0.875rem] w-px bg-gray-700 border-0" />
</>
}
} else {
view! { <></> }
}}
<div class="flex flex-row gap-2 items-center">
{social
Expand Down
1 change: 1 addition & 0 deletions src/components/esta_semana_en_rust/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use leptos::{component, create_signal, view, IntoView, SignalGet, SignalUpdate};

use crate::components::button_link::ButtonLink;

#[must_use]
#[component]
pub fn Header() -> impl IntoView {
let (is_open, set_is_open) = create_signal(false);
Expand Down
3 changes: 2 additions & 1 deletion src/components/esta_semana_en_rust/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ fn get_year() -> i32 {
chrono::Utc::now().year()
}

#[component]
// This is a common Layout component that will be used by all pages.
#[component]
#[must_use]
pub fn Layout(
#[prop(into, default=format!("Blog de Rust Lang en Español {}", get_year()))] title: String,
#[prop(into, default="Somos una comunidad de Rust hispana, buscamos la promoción del lenguaje de programación Rust.".to_string())]
Expand Down
15 changes: 9 additions & 6 deletions src/components/feature_articles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ use crate::{
};
use leptos_mdx::mdx::Mdx;

/// # Panics
/// If no article is found with the tag "esta semana en rust", the call to `unwrap()` will panic.
/// If no article is found with the tag "anuncio de la comunidad", the second `unwrap()` will panic.
/// If the "video" attribute is missing in any `YouTube` component, the `unwrap()` inside the closure will panic.
/// If the value of the "video" attribute is None, the second `unwrap()` will also panic.
pub async fn featured_articles() -> impl IntoView {
let articles = ARTICLES.read().await.clone();
let _invalid_tags = [
Expand All @@ -24,15 +29,13 @@ pub async fn featured_articles() -> impl IntoView {
let esta_semana_en_rust = articles
.clone()
.into_iter()
.filter(|article| filter_article_by_tag(article.clone(), "esta semana en rust".to_string()))
.filter(|article| filter_article_by_tag(article, "esta semana en rust"))
.take(1)
.collect::<Vec<Article>>();
let esta_semana_en_rust = esta_semana_en_rust.first().unwrap().to_owned();
let anuncio_de_la_comunidad = articles
.into_iter()
.filter(|article| {
filter_article_by_tag(article.clone(), "anuncio de la comunidad".to_string())
})
.filter(|article| filter_article_by_tag(article, "anuncio de la comunidad"))
.take(1)
.collect::<Vec<Article>>();

Expand Down Expand Up @@ -64,9 +67,9 @@ pub async fn featured_articles() -> impl IntoView {
}

#[must_use]
pub fn filter_article_by_tag(article: Article, tag: String) -> bool {
pub fn filter_article_by_tag(article: &Article, tag: &str) -> bool {
if let Some(tags) = &article.tags {
tags.contains(&tag)
tags.contains(&tag.to_string())
} else {
false
}
Expand Down
1 change: 1 addition & 0 deletions src/components/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::components::button_link::ButtonLink;
use crate::components::icons::logo_rust_page::LogoRustPageIcon;

#[component]
#[must_use]
pub fn Header() -> impl IntoView {
let (is_open, set_is_open) = create_signal(false);

Expand Down
3 changes: 2 additions & 1 deletion src/components/icons/comments.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use leptos::*;
use leptos::{component, view, IntoView};

#[component]
#[must_use]
pub fn CommentIcon(
#[prop(default = 40)] size: u32,
#[prop(into, default = "fill-black".to_string())] class: String,
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/github.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use leptos::{component, view, IntoView};

#[component]
#[must_use]
pub fn GithubIcon(
#[prop(default = 40)] size: u32,
#[prop(into, default = "fill-black".to_string())] class: String,
Expand Down
3 changes: 2 additions & 1 deletion src/components/icons/linkedin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use leptos::*;
use leptos::{component, view, IntoView};

#[component]
#[must_use]
pub fn LinkedinIcon(
#[prop(default = 40)] size: u32,
#[prop(into, default = "fill-black".to_string())] class: String,
Expand Down
3 changes: 2 additions & 1 deletion src/components/icons/logo_rust_page.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use leptos::*;
use leptos::{component, view, IntoView};

#[component]
#[must_use]
pub fn LogoRustPageIcon(
#[prop(default = 40)] size: u32,
#[prop(into, default = "dark:fill-[#e2cea9]".to_string())] class: String,
Expand Down
2 changes: 2 additions & 0 deletions src/components/icons/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub mod twitter;
pub mod website;

#[component]
#[must_use]
#[allow(clippy::needless_pass_by_value)]
pub fn StrToIcon(
#[prop(into)] v: String,
#[prop(default = 40)] size: u32,
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/next.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use leptos::{component, view, IntoView};

#[component]
#[must_use]
pub fn NextIcon(
#[prop(default = 40)] size: u32,
#[prop(into, default = "fill-black".to_string())] class: String,
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/twitter.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use leptos::{component, view, IntoView};

#[component]
#[must_use]
pub fn TwitterIcon(
#[prop(default = 40)] size: u32,
#[prop(into, default = "fill-black".to_string())] class: String,
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/website.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use leptos::{component, view, IntoView};

#[component]
#[must_use]
pub fn WebsiteIcon(
#[prop(default = 40)] size: u32,
#[prop(into, default = "fill-black".to_string())] class: String,
Expand Down
3 changes: 2 additions & 1 deletion src/components/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ fn get_year() -> i32 {
chrono::Utc::now().year()
}

#[component]
// This is a common Layout component that will be used by all pages.
#[component]
#[must_use]
pub fn Layout(
#[prop(into, default=format!("Blog de Rust Lang en Español {}", get_year()))] title: String,
#[prop(into, default="rustlanges_preview.webp".to_string())] slug: String,
Expand Down
2 changes: 1 addition & 1 deletion src/components/markdown_render.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use leptos::*;
use leptos::{component, view, IntoView};
use leptos_mdx::mdx::{Components, Mdx, MdxComponentProps};

use crate::components::mdx::{
Expand Down
1 change: 1 addition & 0 deletions src/components/mdx/center.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use leptos::{component, view, Children, IntoView};

#[component]
#[must_use]
pub fn Center(children: Children) -> impl IntoView {
view! { <div class="mx-auto">{children()}</div> }
}
2 changes: 2 additions & 0 deletions src/components/mdx/youtube.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use leptos::{component, view, IntoView};

#[component]
#[allow(clippy::needless_pass_by_value)]
#[must_use]
pub fn Youtube(video: String) -> impl IntoView {
view! {
<div class="layout">
Expand Down
3 changes: 3 additions & 0 deletions src/components/pagination_buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::components::icons::StrToIcon;
use leptos::{component, view, IntoView, Show};

#[component]
#[must_use]
pub fn PaginationButtons(
hide: bool,
current_page: Option<usize>,
Expand Down Expand Up @@ -34,6 +35,7 @@ pub fn PaginationButtons(
}

#[component]
#[must_use]
pub fn PreviousPageButton(page: Option<usize>) -> impl IntoView {
let page = page.unwrap_or(0);

Expand All @@ -57,6 +59,7 @@ pub fn PreviousPageButton(page: Option<usize>) -> impl IntoView {
}

#[component]
#[must_use]
pub fn NextPageButton(page: Option<usize>) -> impl IntoView {
let page = page.unwrap_or(0);
let link = format!("/pages/{}.html", page + 1);
Expand Down
Loading
Loading