Skip to content

Commit 33eab70

Browse files
committed
✨ sponsors
1 parent e58dd95 commit 33eab70

File tree

6 files changed

+71
-7
lines changed

6 files changed

+71
-7
lines changed

app/app.config.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ export default defineAppConfig({
2020
},
2121
search: true,
2222
colorMode: true,
23-
links: [{
24-
'icon': 'i-mdi-github',
25-
'to': 'https://github.com/Lomkit/laravel-rest-api',
26-
'target': '_blank',
27-
'aria-label': 'Laravel Rest Api on Github'
28-
}]
23+
links: [
24+
{
25+
'icon': 'i-mdi-github',
26+
'to': 'https://github.com/Lomkit/laravel-rest-api',
27+
'target': '_blank',
28+
'aria-label': 'Laravel Rest Api on Github'
29+
}
30+
]
2931
},
3032
footer: {
3133
credits: 'Copyright © ' + (new Date().getFullYear()),
@@ -49,5 +51,14 @@ export default defineAppConfig({
4951
target: '_blank'
5052
}]
5153
}
54+
},
55+
sponsors: {
56+
title: 'Sponsors',
57+
links: [{
58+
icon: 'i-mdi-hand-heart-outline',
59+
label: 'Become a sponsor',
60+
to: 'https://github.com/sponsors/GautierDele',
61+
target: '_blank'
62+
}]
5263
}
5364
})

app/components/Sponsors/Ads.vue

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script setup lang="ts">
2+
const sponsor = useSponsors()
3+
</script>
4+
5+
<template>
6+
<div class="space-y-3">
7+
<UPageCard :to="sponsor.link" target="_blank" :ui="{ header: { padding: 'p-0 sm:p-0' }, rounded: 'rounded', body: { padding: 'p-2 sm:p-2', base: 'text-center' } }">
8+
<template #header>
9+
<div class="px-2 py-2">
10+
<UColorModeImage :dark="sponsor.logo.dark" :light="sponsor.logo.light" :alt="sponsor.name" />
11+
</div>
12+
</template>
13+
<p class="text-sm dark:text-gray-400 text-gray-500 pb-1">
14+
{{ sponsor.text }}
15+
</p>
16+
</UPageCard>
17+
</div>
18+
</template>

app/composables/useSponsors.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export const useSponsors = () => {
2+
const sponsors = [{
3+
name: 'XEFI',
4+
text: 'French leader in IT performance support',
5+
logo: {
6+
light: '/sponsors/xefi-light.png',
7+
dark: '/sponsors/xefi-dark.png',
8+
},
9+
link: 'https://xefi.com'
10+
}]
11+
12+
function getRandomElement<T>(arr: T[]): T | undefined {
13+
if (arr.length === 0) {
14+
return undefined;
15+
}
16+
17+
const randomIndex = Math.floor(Math.random() * arr.length);
18+
19+
return arr[randomIndex];
20+
}
21+
22+
return computed(() => getRandomElement(sponsors));
23+
}

app/pages/[...slug].vue

+13-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ definePageMeta({
66
})
77
88
const route = useRoute()
9-
const { toc, seo } = useAppConfig()
9+
const { toc, seo, sponsors } = useAppConfig()
1010
1111
const { data: page } = await useAsyncData(route.path, () => queryContent(route.path).findOne())
1212
if (!page.value) {
@@ -87,6 +87,18 @@ const links = computed(() => [toc?.bottom?.edit && {
8787
:title="toc.bottom.title"
8888
:links="links"
8989
/>
90+
91+
<UDivider
92+
v-if="sponsors?.length"
93+
type="dashed"
94+
/>
95+
96+
<UPageLinks
97+
:title="sponsors.title"
98+
:links="sponsors.links"
99+
/>
100+
101+
<SponsorsAds />
90102
</div>
91103
</template>
92104
</UContentToc>

public/sponsors/xefi-dark.png

45.1 KB
Loading

public/sponsors/xefi-light.png

46.5 KB
Loading

0 commit comments

Comments
 (0)