mirror of
https://github.com/ProjectSegfault/website.git
synced 2024-11-09 17:42:02 +05:30
Add user count
Signed-off-by: Odyssey346 <odyssey346@disroot.org>
This commit is contained in:
parent
2baba07731
commit
a891b13bcd
@ -9,6 +9,7 @@ export const load = (async () => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
users: get(pubnixUsers),
|
users: get(pubnixUsers),
|
||||||
|
onlineUserCount: get(pubnixUsers).length,
|
||||||
...meta
|
...meta
|
||||||
}
|
}
|
||||||
}) satisfies PageServerLoad;
|
}) satisfies PageServerLoad;
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
import User, { type UserType } from "./User.svelte";
|
import User, { type UserType } from "./User.svelte";
|
||||||
|
|
||||||
const isOnline = (user: UserType) => user.online;
|
const isOnline = (user: UserType) => user.online;
|
||||||
|
|
||||||
|
const onlineUserCount = data.users.users.filter(isOnline).length;
|
||||||
|
|
||||||
|
const userCount = data.users.users.length;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="h1-no-lg flex flex-col sm:(flex-row items-center) gap-4">
|
<div class="h1-no-lg flex flex-col sm:(flex-row items-center) gap-4">
|
||||||
@ -33,6 +37,7 @@
|
|||||||
|
|
||||||
{#if !data.users.error}
|
{#if !data.users.error}
|
||||||
{#if data.users.users.some(isOnline)}
|
{#if data.users.users.some(isOnline)}
|
||||||
|
<p>There are {onlineUserCount} users online out of {userCount} users.</p>
|
||||||
<div class="flex flex-row flex-wrap gap-4">
|
<div class="flex flex-row flex-wrap gap-4">
|
||||||
{#each data.users.users as user}
|
{#each data.users.users as user}
|
||||||
{#if user.online}
|
{#if user.online}
|
||||||
|
@ -3,12 +3,15 @@
|
|||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
import User from "../User.svelte";
|
import User from "../User.svelte";
|
||||||
|
|
||||||
|
const userCount = data.users.users.length;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1>{data.title}</h1>
|
<h1>{data.title}</h1>
|
||||||
|
|
||||||
{#if !data.users.error}
|
{#if !data.users.error}
|
||||||
{#if data.users.users.length > 0}
|
{#if data.users.users.length > 0}
|
||||||
|
<p>There are {userCount} users on the pubnix.</p>
|
||||||
<div class="flex flex-row flex-wrap gap-4">
|
<div class="flex flex-row flex-wrap gap-4">
|
||||||
{#each data.users.users as user}
|
{#each data.users.users as user}
|
||||||
<User {user} />
|
<User {user} />
|
||||||
|
Loading…
Reference in New Issue
Block a user