feat: add github stars to landing page (#543)

* added github stars

* Update Navigation.svelte

* debug data

* remove prerender

* feat: githubstar change

* pass data from server to client

* remove console.log

---------

Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
Pranav Murali
2025-01-22 15:39:22 +01:00
committed by GitHub
co-authored by Rotimi Best
parent 8eb9236bc0
commit 29fa038760
5 changed files with 79 additions and 53 deletions
@@ -0,0 +1,15 @@
export async function load({ fetch }) {
let githubStars = 0;
try {
const response = await fetch('http://api.github.com/repos/classroomio/classroomio');
const data = await response.json();
githubStars = data?.stargazers_count || 0;
} catch (error) {
console.error('Error fetching GitHub stars:', error);
}
return {
githubStars
};
}
@@ -25,7 +25,7 @@
<MetaTags {...metaTags} />
<div class="overflow-hidden bg-white">
<Navigation />
<Navigation stars={data.githubStars} />
<PageTransition url={data.url}>
{#if $page.status === 404}
+3 -2
View File
@@ -2,10 +2,11 @@ import type { MetaTagsProps } from 'svelte-meta-tags';
export const prerender = true;
export function load({ url }) {
export function load({ url, data }) {
return {
baseMetaTags: getBaseMetaTags(url),
url: url.pathname
url: url.pathname,
...data,
};
}