Skip to content

Commit

Permalink
Show contributors from GitHub API
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechu10 committed Nov 17, 2024
1 parent 52736ca commit dc3c001
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/api_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub fn get_repo_stats() -> RepoStats {
CACHED_VALUES.repo_stats.clone()
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Contributor {
pub login: String,
pub avatar_url: String,
Expand Down
16 changes: 14 additions & 2 deletions src/pages/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ fn CommunitySection() -> View {
let stars_text = format!("{}.{}k", stars_hundreds / 10, stars_hundreds % 10);

let contributors = crate::api_stats::get_contributors();
let contributors_len = contributors.len();

let crates_io_downloads = crate::api_stats::get_crate_io_stats()._crate.downloads;

Expand All @@ -188,7 +189,7 @@ fn CommunitySection() -> View {
p(class="text-sm font-normal") { "on GitHub" }
}
div(class="px-4") {
(format!("{} Contributors", contributors.len()))
(format!("{} Contributors", contributors_len))
p(class="text-sm font-normal") { "on GitHub" }
}
div(class="px-4") {
Expand All @@ -198,7 +199,18 @@ fn CommunitySection() -> View {
}
div(class="mt-5 text-center") {
p { "Sycamore is made possible by all our " a(class="underline", href="https://github.com/sycamore-rs/sycamore/graphs/contributors") { "community contributors" } ". Thank you!" }
img(src="https://contrib.rocks/image?repo=sycamore-rs/sycamore", alt="Contributors", class="mx-auto my-2 sm:max-w-[600px]")

div(class="mx-auto my-2 sm:max-w-[800px] flex flex-wrap justify-center gap-2") {
Indexed(
list=contributors,
view=|contributor| view! {
a(href=contributor.html_url) {
img(src=contributor.avatar_url, title=contributor.login, class="rounded-full w-12 h-12 hover:shadow-lg transition", loading="lazy")
}
}
)
}

p { "Interested in contributing as well? Check out our " a(class="underline", href="https://github.com/sycamore-rs/sycamore/blob/main/CONTRIBUTING.md") { "contribution guide" } "." }
}
}
Expand Down

0 comments on commit dc3c001

Please sign in to comment.