Skip to content

Commit 0b5b17b

Browse files
authored
Merge pull request #5 from ILDaviz/main
Draft: [features] Include contributors section and add tailwind css
2 parents 4f6da41 + d29e7aa commit 0b5b17b

8 files changed

Lines changed: 818 additions & 29 deletions

File tree

docs/.vitepress/config.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default defineConfig({
8787
],
8888
footer: {
8989
message: 'Made with ❤️',
90-
copyright: 'Copyright © 2024-present Saeed Vaziry'
90+
copyright: 'Copyright © 2024-present Saeed Vaziry and TweakPHP contributors',
9191
}
9292
}
9393
})

docs/.vitepress/theme/MyLayout.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script setup>
2+
import Theme from 'vitepress/theme'
3+
import Contributors from "./components/Contributors.vue";
4+
5+
const { Layout } = Theme
6+
</script>
7+
8+
<template>
9+
<Layout>
10+
<template #home-features-after>
11+
<div
12+
class="flex flex-col justify-center items-center w-full mt-10"
13+
>
14+
<h3 class="text-4xl! font-semibold! text-center mb-4">Contributors</h3>
15+
<Contributors />
16+
</div>
17+
</template>
18+
</Layout>
19+
</template>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<script lang="ts" setup>
2+
import { ref, onMounted } from 'vue'
3+
4+
const contributors = ref<any[]>([])
5+
6+
const fromRepo = (repo: string) =>
7+
fetch(`https://api.github.com/repos/tweakphp/${repo}/contributors`)
8+
.then((res) => res.json())
9+
.catch(() => [])
10+
11+
const getContributors = async () => {
12+
const users = await Promise.all([
13+
fromRepo('tweakphp'),
14+
fromRepo('docs'),
15+
fromRepo('client'),
16+
fromRepo('.github'),
17+
])
18+
19+
contributors.value = users
20+
.reduce((acc, data = []) => {
21+
if (!Array.isArray(data)) return acc
22+
return [...acc, ...data.filter(i => i.login)]
23+
}, [])
24+
.reduce((acc, user) => {
25+
const existingUser = acc.find(u => u.id === user.id)
26+
if (existingUser) {
27+
existingUser.contributions += user.contributions
28+
return acc
29+
}
30+
return [...acc, {
31+
id: user.id,
32+
username: user.login,
33+
contributions: user.contributions,
34+
avatar_url: user.avatar_url
35+
}]
36+
}, [])
37+
}
38+
39+
onMounted(() => {
40+
getContributors()
41+
})
42+
</script>
43+
44+
<template>
45+
<div class="text-lg text-center leading-7 my-10 px-5">
46+
<div class="flex flex-wrap gap-2">
47+
<a
48+
v-for="contributor of contributors"
49+
:key="contributor.id"
50+
v-tooltip="contributor.username"
51+
:href="`https://github.com/${contributor.username}`"
52+
:aria-label="contributor.username"
53+
rel="noopener noreferrer"
54+
target="_blank"
55+
>
56+
<img
57+
:src="contributor.avatar_url"
58+
:alt="contributor.username"
59+
:aria-label="contributor.username"
60+
loading="lazy"
61+
width="50"
62+
height="50"
63+
class="w-15 h-15 min-w-15 min-h-15 !rounded-full"
64+
/>
65+
</a>
66+
</div>
67+
</div>
68+
</template>

docs/.vitepress/theme/index.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
// https://vitepress.dev/guide/custom-theme
2-
import {h} from 'vue'
32
import Theme from 'vitepress/theme'
43
import './style.css'
4+
import MyLayout from "./MyLayout.vue";
5+
import Contributors from "./components/Contributors.vue";
56

67
export default {
78
extends: Theme,
8-
Layout: () => {
9-
return h(Theme.Layout, null, {
10-
// https://vitepress.dev/guide/extending-default-theme#layout-slots
11-
})
12-
},
13-
enhanceApp({app, router, siteData}) {
14-
// app.component('Component', Component)
15-
},
9+
Layout: MyLayout,
10+
enhanceApp({ app }) {
11+
app.component('Contributors', Contributors);
12+
}
1613
}

docs/.vitepress/theme/style.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "tailwindcss";
2+
13
:root {
24
--vp-c-brand-1: #be185d;
35
--vp-c-brand-2: #db2777;

0 commit comments

Comments
 (0)