Skip to content

Commit f8cc963

Browse files
committed
refactor: update landing sponsors/contributors
1 parent 616597e commit f8cc963

File tree

2 files changed

+50
-15
lines changed

2 files changed

+50
-15
lines changed

app/composables/useContributors.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export interface Contributor {
2+
name: string
3+
username: string
4+
profile: string
5+
avatar: string
6+
}
7+
8+
export async function useContributors(): Promise<Contributor[] | undefined> {
9+
const { docs: docsConfig } = useAppConfig()
10+
if (!docsConfig.github || !docsConfig.landing?.contributors) {
11+
return
12+
}
13+
const { contributors = [] } = await await $fetch<{ contributors: { username: string }[] }>(
14+
`https://ungh.cc/repos/${docsConfig.github}/contributors`,
15+
)
16+
return contributors
17+
.filter((c) => !c.username.includes('bot'))
18+
.map((c) => ({
19+
name: `@${c.username}`,
20+
username: c.username,
21+
profile: `https://github.com/${c.username}`,
22+
avatar: `https://github.com/${c.username}.png`,
23+
}))
24+
}

app/pages/index.vue

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ const { data: latest } = await useAsyncData(() =>
9898
)
9999
100100
const { data: sponsors } = await useAsyncData(() => useSponsors())
101+
const { data: contributors } = await useAsyncData(() => useContributors())
101102
</script>
102103

103104
<template>
@@ -190,48 +191,43 @@ const { data: sponsors } = await useAsyncData(() => useSponsors())
190191
</template>
191192
</UPageSection>
192193

193-
<UPageSection v-if="landing.contributors && landing._github" id="contributors" title="💛 Contributors">
194-
<div id="contributors" class="flex justify-center">
195-
<a :href="`https://github.com/${landing._github}/graphs/contributors`" target="_blank">
196-
<img :src="`https://contrib.rocks/image?repo=${landing._github}`" />
197-
</a>
198-
</div>
199-
</UPageSection>
200-
201-
<UPageSection v-if="sponsors?.sponsors.length" title="💜 Sponsors">
194+
<UPageSection v-if="sponsors?.sponsors.length" title="Sponsors">
202195
<div id="sponsors" class="flex flex-col items-center">
203196
<div
204197
v-for="(tier, i) of sponsors.sponsors.slice(0, 2)"
205198
:key="i"
206-
class="flex flex-wrap justify-center gap-4 mb-6 mt-6 max-w-4xl"
199+
class="flex flex-wrap justify-center gap-4 max-w-4xl mb-8 mt-8"
207200
>
208201
<div v-for="s in tier" :key="s.name" class="flex items-center gap-2 max-w-[300px]">
209202
<a
210203
:href="s.website"
211204
target="_blank"
212205
class="flex items-center gap-2"
213-
:class="`font-size-${i === 0 ? '4xl' : i === 1 ? '3xl' : 'lg'}`"
206+
:class="`font-size-${i === 0 ? '3xl' : i === 1 ? 'xl' : 'lg'}`"
214207
>
215208
<img
216209
v-if="s.image"
217210
:src="s.image"
218211
:alt="s.name"
219212
class="object-contain rounded-lg"
220-
:class="`w-${i === 0 ? 16 : 10} h-${i === 0 ? 16 : 10}`"
213+
:style="{
214+
width: i === 0 ? '80px' : '48px',
215+
height: i === 0 ? '80px' : '48px',
216+
}"
221217
/>
222218
<span v-if="i < 2" class="text-lg font-semibold">{{ s.name }}</span>
223219
</a>
224220
</div>
225221
</div>
226-
<UAvatarGroup class="flex flex-wrap justify-center gap-4 mb-6 mt-6">
222+
<UAvatarGroup class="flex flex-wrap justify-center gap-4">
227223
<UTooltip v-for="s in sponsors.sponsors[2]" :key="s.name" :text="s.name" placement="top">
228224
<a :href="s.website" target="_blank">
229225
<UAvatar :alt="s.name" :src="s.image" size="lg" />
230226
</a>
231227
</UTooltip>
232228
</UAvatarGroup>
233-
<UAvatarGroup class="flex flex-wrap justify-center gap-4 mb-6 mt-6">
234-
<UTooltip v-for="s in sponsors.sponsors[3]" :key="s.name" :text="s.name" placement="top">
229+
<UAvatarGroup class="flex flex-wrap justify-center gap-4">
230+
<UTooltip v-for="s in sponsors.sponsors[3]" :key="s.name" :text="s.name">
235231
<a :href="s.website" target="_blank">
236232
<UAvatar :alt="s.name" :src="s.image" style="opacity: 0.5" />
237233
</a>
@@ -249,5 +245,20 @@ const { data: sponsors } = await useAsyncData(() => useSponsors())
249245
</UButton>
250246
</div>
251247
</UPageSection>
248+
249+
<UPageSection v-if="contributors?.length" id="contributors" title="Contributors">
250+
<UAvatarGroup class="flex flex-wrap justify-center gap-4">
251+
<UTooltip v-for="c in contributors" :key="c.username" :text="c.name">
252+
<a :href="c.profile" target="_blank">
253+
<UAvatar :alt="c.name" :src="c.avatar" size="3xl" />
254+
</a>
255+
</UTooltip>
256+
</UAvatarGroup>
257+
<div class="text-center">
258+
<UButton v-if="sponsors.username" :to="`https://github.com/${landing._github}`" target="_blank" color="neutral">
259+
Contribute on GitHub
260+
</UButton>
261+
</div>
262+
</UPageSection>
252263
</div>
253264
</template>

0 commit comments

Comments
 (0)