-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from s1lvax/feature/discord-call-to-action
Improvements to Index
- Loading branch information
Showing
7 changed files
with
154 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<script lang="ts"> | ||
import { formatDate } from '$lib/utils/formatDate'; | ||
import type { User } from '@prisma/client'; | ||
export let users: User[] = []; | ||
</script> | ||
|
||
<div class="mt-12 py-32 sm:py-24"> | ||
<div class="mx-auto grid max-w-7xl gap-20 px-6 lg:px-8 xl:grid-cols-3"> | ||
<div class="max-w-xl"> | ||
<div class="flex flex-col space-y-4"> | ||
<h2 class="text-pretty text-3xl font-semibold tracking-tight sm:text-4xl"> | ||
Meet some of our Users | ||
</h2> | ||
</div> | ||
<p class="mt-6 text-lg leading-8 text-muted-foreground"> | ||
Explore the profile of some of our users | ||
</p> | ||
</div> | ||
<ul role="list" class="grid gap-x-8 gap-y-12 sm:grid-cols-2 sm:gap-y-16 xl:col-span-2"> | ||
{#each users as user} | ||
<a href="/{user.githubUsername}"> | ||
<li> | ||
<div | ||
class="flex items-center gap-x-6 transition-transform duration-300 ease-in-out hover:scale-105" | ||
> | ||
<img | ||
class="h-16 w-16 rounded-full" | ||
src="https://github.com/{user.githubUsername}.png" | ||
alt="{user.githubUsername}'s avatar" | ||
/> | ||
<div> | ||
<h3 class="text-base font-semibold leading-7 tracking-tight"> | ||
{user.githubUsername} | ||
</h3> | ||
<p class="text-sm font-semibold leading-6 text-muted-foreground"> | ||
Joined on the {formatDate(user.createdAt)} | ||
</p> | ||
</div> | ||
</div> | ||
</li> | ||
</a> | ||
{/each} | ||
</ul> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
export const formatDate = (dateInput: Date | string): string => { | ||
// If input is a string, convert it to a Date object | ||
const date = typeof dateInput === 'string' ? new Date(dateInput) : dateInput; | ||
|
||
// Ensure the input is a valid date | ||
// ensure the input is a valid date | ||
if (isNaN(date.getTime())) { | ||
throw new Error('Invalid date'); | ||
} | ||
|
||
// Return formatted date and time | ||
return date.toLocaleString(); | ||
// get data | ||
const year = date.getFullYear(); | ||
const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-based, so add 1 | ||
const day = String(date.getDate()).padStart(2, '0'); | ||
|
||
return `${year}.${month}.${day}`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { prisma } from '$lib/server/prisma'; | ||
import type { PageServerLoad } from './$types'; | ||
|
||
export const load: PageServerLoad = async () => { | ||
// Fetch 6 random users | ||
const users = await prisma.user.findMany({ | ||
take: 6, | ||
orderBy: { | ||
id: 'asc' | ||
}, | ||
where: { | ||
id: { | ||
in: ( | ||
await prisma.user.findMany({ | ||
select: { id: true }, | ||
orderBy: { | ||
id: 'asc' | ||
} | ||
}) | ||
).map((user) => user.id) | ||
} | ||
} | ||
}); | ||
|
||
return { | ||
users | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters