|
23 | 23 | import * as Tooltip from '$lib/components/ui/tooltip/index'; |
24 | 24 | import favicon from '$lib/assets/logo.svg'; |
25 | 25 | import { PUBLIC_INSTANCE_URL } from '#consts/urls'; |
26 | | - import { |
27 | | - SiGithub, |
28 | | - SiBuymeacoffee, |
29 | | - SiLiberapay, |
30 | | - SiKofi, |
31 | | - SiPatreon, |
32 | | - SiUptimekuma |
33 | | - } from '@icons-pack/svelte-simple-icons'; |
34 | 26 | import { env } from '$env/dynamic/public'; |
35 | | -
|
| 27 | + import { SiGithub, SiUptimekuma } from '@icons-pack/svelte-simple-icons'; |
36 | 28 | const { isAuthenticated, user: userData } = useAuth(); |
37 | 29 |
|
38 | 30 | let { children } = $props(); |
|
100 | 92 | } |
101 | 93 | ]); |
102 | 94 |
|
103 | | - $effect(() => { |
104 | | - type DonationKey = |
105 | | - | 'PUBLIC_BUY_ME_A_COFFEE' |
106 | | - | 'PUBLIC_LIBERAPAY' |
107 | | - | 'PUBLIC_KO_FI' |
108 | | - | 'PUBLIC_PATREON'; |
109 | | -
|
110 | | - interface DonationPlatform { |
111 | | - key: DonationKey; |
112 | | - name: string; |
113 | | - icon: any; |
114 | | - } |
115 | | -
|
116 | | - const donationPlatforms: DonationPlatform[] = [ |
117 | | - { key: 'PUBLIC_BUY_ME_A_COFFEE', name: 'Support by buying a coffee', icon: SiBuymeacoffee }, |
118 | | - { key: 'PUBLIC_LIBERAPAY', name: 'Support by Liberapay', icon: SiLiberapay }, |
119 | | - { key: 'PUBLIC_KO_FI', name: 'Support by Ko-Fi', icon: SiKofi }, |
120 | | - { key: 'PUBLIC_PATREON', name: 'Support by Patreon', icon: SiPatreon } |
| 95 | + $effect.pre(() => { |
| 96 | + const donationPlatforms = [ |
| 97 | + { key: 'PUBLIC_BUY_ME_A_COFFEE', name: 'Buy Me A Coffee', path: 'SiBuymeacoffee' }, |
| 98 | + { key: 'PUBLIC_LIBERAPAY', name: 'Liberapay', path: 'SiLiberapay' }, |
| 99 | + { key: 'PUBLIC_KO_FI', name: 'Ko-Fi', path: 'SiKofi' }, |
| 100 | + { key: 'PUBLIC_PATREON', name: 'Patreon', path: 'SiPatreon' } |
121 | 101 | ]; |
122 | | - // Get the current largest order in footerLinks |
123 | | - let maxOrder = footerLinks.reduce((max, link) => Math.max(max, link.order ?? 0), 0); |
124 | 102 |
|
125 | | - donationPlatforms.forEach(({ key, name, icon }) => { |
| 103 | + donationPlatforms.forEach(async ({ key, name, path }) => { |
126 | 104 | const href = (env as Record<string, string | undefined>)[key]; |
127 | | - if (href) { |
128 | | - maxOrder += 1; // increment for each new donation link |
129 | | - footerLinks.push({ href, name, icon, order: maxOrder }); |
| 105 | +
|
| 106 | + if (href && !footerLinks.some((link) => link.href === href)) { |
| 107 | + const module = await import(`@icons-pack/svelte-simple-icons/icons/${path}.svelte`); |
| 108 | +
|
| 109 | + footerLinks.push({ |
| 110 | + href, |
| 111 | + name, |
| 112 | + icon: module.default, |
| 113 | + order: footerLinks.length + 1 |
| 114 | + }); |
130 | 115 | } |
131 | 116 | }); |
132 | 117 | }); |
|
0 commit comments