chore: load stars on client

This commit is contained in:
Rotimi Best
2025-01-30 10:18:16 +01:00
parent 29fa038760
commit 4e2d5dd16f
4 changed files with 24 additions and 26 deletions
@@ -1,15 +0,0 @@
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
};
}
@@ -1,13 +1,13 @@
<script>
import { dev } from '$app/environment';
import { page } from '$app/stores';
import { MetaTags } from 'svelte-meta-tags';
import Navigation from '$lib/Navigation/Navigation.svelte';
import Footer from '$lib/Footer/Footer.svelte';
import PageTransition from './transition.svelte';
import Navigation from '$lib/Navigation/Navigation.svelte';
import NotFound from '$lib/NotFound/NotFound.svelte';
import extend from 'just-extend';
import { dev } from '$app/environment';
import { onMount } from 'svelte';
import { MetaTags } from 'svelte-meta-tags';
import PageTransition from './transition.svelte';
import '../app.css';
@@ -25,7 +25,7 @@
<MetaTags {...metaTags} />
<div class="overflow-hidden bg-white">
<Navigation stars={data.githubStars} />
<Navigation />
<PageTransition url={data.url}>
{#if $page.status === 404}
+2 -3
View File
@@ -2,11 +2,10 @@ import type { MetaTagsProps } from 'svelte-meta-tags';
export const prerender = true;
export function load({ url, data }) {
export function load({ url }) {
return {
baseMetaTags: getBaseMetaTags(url),
url: url.pathname,
...data,
url: url.pathname
};
}