diff --git a/src/routes/pubnix/+page.server.ts b/src/routes/pubnix/+page.server.ts index f48f33c..1c33249 100644 --- a/src/routes/pubnix/+page.server.ts +++ b/src/routes/pubnix/+page.server.ts @@ -9,6 +9,7 @@ export const load = (async () => { return { users: get(pubnixUsers), + onlineUserCount: get(pubnixUsers).length, ...meta } }) satisfies PageServerLoad; diff --git a/src/routes/pubnix/+page.svelte b/src/routes/pubnix/+page.svelte index 6b55f38..516dc41 100644 --- a/src/routes/pubnix/+page.svelte +++ b/src/routes/pubnix/+page.svelte @@ -5,6 +5,10 @@ import User, { type UserType } from "./User.svelte"; const isOnline = (user: UserType) => user.online; + + const onlineUserCount = data.users.users.filter(isOnline).length; + + const userCount = data.users.users.length;
@@ -33,6 +37,7 @@ {#if !data.users.error} {#if data.users.users.some(isOnline)} +

There are {onlineUserCount} users online out of {userCount} users.

{#each data.users.users as user} {#if user.online} diff --git a/src/routes/pubnix/users/+page.svelte b/src/routes/pubnix/users/+page.svelte index 6610b2e..87e75db 100644 --- a/src/routes/pubnix/users/+page.svelte +++ b/src/routes/pubnix/users/+page.svelte @@ -3,12 +3,15 @@ export let data: PageData; import User from "../User.svelte"; + + const userCount = data.users.users.length;

{data.title}

{#if !data.users.error} {#if data.users.users.length > 0} +

There are {userCount} users on the pubnix.

{#each data.users.users as user}