Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 32 additions & 35 deletions src/frontend/src/components/FooterLinks.astro
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
---
import { Icon } from '@astrojs/starlight/components';
import config from 'virtual:starlight/user-config';
import { socialConfig } from '../../config/socials.config';

type CommunityLink = {
icon: (typeof socialConfig)[number]['icon'] | 'reddit';
label: string;
href: string;
};

const getSocialLink = (label: string, displayLabel = label): CommunityLink | null => {
const link = socialConfig.find((social) => social.label === label);
return link ? { icon: link.icon, label: displayLabel, href: link.href } : null;
};

const communityLinks = [
getSocialLink('X', 'X (Twitter)'),
getSocialLink('BlueSky'),
getSocialLink('GitHub'),
getSocialLink('Discord'),
{
icon: 'reddit',
label: 'Reddit',
href: 'https://www.reddit.com/r/aspiredotdev',
},
getSocialLink('YouTube'),
getSocialLink('Twitch'),
getSocialLink('Blog', Astro.locals.t('footer.blog' as any)),
].filter((link): link is CommunityLink => link !== null);

const links = config.social || [];
const gitHubLink = links.find((link) => link.label === 'GitHub')?.href ?? null;
const discordLink = links.find((link) => link.label === 'Discord')?.href ?? null;
const is404 =
Astro.locals.starlightRoute?.entry?.slug === '404' ||
/^\/(?:[^/]+\/)?404\/?$/.test(Astro.url.pathname);
Expand All @@ -15,40 +38,14 @@ const is404 =
<div class="footer-column">
<p class="footer-heading">{Astro.locals.t('footer.community' as any)}</p>
<ul class="footer-links">
<li>
<a href="https://x.com/aspiredotdev" target="_blank" rel="noopener noreferrer">
<Icon name="x.com" size="1em" />
Follow
</a>
</li>
{gitHubLink && (
<li>
<a href={gitHubLink} target="_blank" rel="noopener noreferrer">
<Icon name="github" size="1em" />
{Astro.locals.t('footer.collab' as any)}
</a>
</li>
)}
{discordLink && (
{communityLinks.map((link) => (
<li>
<a href={discordLink} target="_blank" rel="noopener noreferrer">
<Icon name="discord" size="1em" />
Discord
<a href={link.href} target="_blank" rel="noopener noreferrer">
<Icon name={link.icon} size="1em" />
{link.label}
</a>
</li>
)}
<li>
<a href="https://www.reddit.com/r/aspiredotdev" target="_blank" rel="noopener noreferrer">
<Icon name="reddit" size="1em" />
{Astro.locals.t('footer.discuss' as any)}
</a>
</li>
<li>
<a href="https://www.youtube.com/@aspiredotdev" target="_blank" rel="noopener noreferrer">
<Icon name="youtube" size="1em" />
{Astro.locals.t('footer.watch' as any)}
</a>
</li>
))}
</ul>
</div>
)
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Lavet med 💜 hos Microsoft",
"opensInNewTab": "åbner i ny fane",
"ask": "Spørg & svar",
"collab": "Samarbejd",
"community": "Fællesskab",
"discuss": "Diskutér",
"watch": "Se",
"blog": "Blog",
"privacy": "Privatliv",
"resources": "Ressourcer",
"legal": "Juridisk",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Mit 💜 bei Microsoft erstellt",
"opensInNewTab": "öffnet in neuem Tab",
"ask": "Fragen & Antworten",
"collab": "Zusammenarbeiten",
"community": "Community",
"discuss": "Diskutieren",
"watch": "Ansehen",
"blog": "Blog",
"privacy": "Datenschutz",
"resources": "Ressourcen",
"legal": "Rechtliches",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Made with 💜 at Microsoft",
"opensInNewTab": "opens in new tab",
"ask": "FAQ",
"collab": "Collaborate",
"community": "Community",
"discuss": "Discuss",
"watch": "Watch",
"blog": "Blog",
"privacy": "Privacy",
"resources": "Resources",
"legal": "Legal",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Hecho con 💜 en Microsoft",
"opensInNewTab": "se abre en una nueva pestaña",
"ask": "Preguntas y respuestas",
"collab": "Colabora",
"community": "Comunidad",
"discuss": "Debatir",
"watch": "Ver bajo demanda",
"blog": "Blog",
"privacy": "Privacidad",
"resources": "Recursos",
"legal": "Legal",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Fait avec 💜 chez Microsoft",
"opensInNewTab": "ouvre dans un nouvel onglet",
"ask": "Questions & Réponses",
"collab": "Collaborer",
"community": "Communauté",
"discuss": "Discuter",
"watch": "Regarder",
"blog": "Blog",
"privacy": "Confidentialité",
"resources": "Ressources",
"legal": "Mentions légales",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Microsoft पर 💜 के साथ बनाया गया",
"opensInNewTab": "नए टैब में खुलता है",
"ask": "प्रश्न & उत्तर",
"collab": "सहयोग करें",
"community": "समुदाय",
"discuss": "चर्चा",
"watch": "देखें",
"blog": "ब्लॉग",
"privacy": "गोपनीयता",
"resources": "संसाधन",
"legal": "कानूनी",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Dibuat dengan 💜 di Microsoft",
"opensInNewTab": "membuka di tab baru",
"ask": "Tanya & Jawab",
"collab": "Kolaborasi",
"community": "Komunitas",
"discuss": "Diskusi",
"watch": "Tonton",
"blog": "Blog",
"privacy": "Privasi",
"resources": "Sumber Daya",
"legal": "Hukum",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Creato con 💜 in Microsoft",
"opensInNewTab": "apre in una nuova scheda",
"ask": "Domande & Risposte",
"collab": "Collabora",
"community": "Community",
"discuss": "Discute",
"watch": "Guarda",
"blog": "Blog",
"privacy": "Privacy",
"resources": "Risorse",
"legal": "Legale",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Microsoft で 💜 を込めて制作",
"opensInNewTab": "新しいタブで開く",
"ask": "質問 & 回答",
"collab": "コラボレーション",
"community": "コミュニティ",
"discuss": "ディスカッション",
"watch": "視聴",
"blog": "ブログ",
"privacy": "プライバシー",
"resources": "リソース",
"legal": "法的情報",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Microsoft에서 💜로 제작",
"opensInNewTab": "새 탭에서 열림",
"ask": "질문 & 답변",
"collab": "협업",
"community": "커뮤니티",
"discuss": "토론",
"watch": "보기",
"blog": "블로그",
"privacy": "개인정보",
"resources": "리소스",
"legal": "법적 고지",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Feito com 💜 na Microsoft",
"opensInNewTab": "abre em nova aba",
"ask": "Pergunte & Responda",
"collab": "Colabore",
"community": "Comunidade",
"discuss": "Discutir",
"watch": "Assistir",
"blog": "Blog",
"privacy": "Privacidade",
"resources": "Recursos",
"legal": "Legal",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Сделано с 💜 в Microsoft",
"opensInNewTab": "открывается в новой вкладке",
"ask": "Вопросы & ответы",
"collab": "Сотрудничать",
"community": "Сообщество",
"discuss": "Обсуждать",
"watch": "Смотреть",
"blog": "Блог",
"privacy": "Конфиденциальность",
"resources": "Ресурсы",
"legal": "Правовая информация",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Microsoft'ta 💜 ile yapıldı",
"opensInNewTab": "yeni sekmede açılır",
"ask": "Sor & Yanıtla",
"collab": "İşbirliği",
"community": "Topluluk",
"discuss": "Tartış",
"watch": "İzle",
"blog": "Blog",
"privacy": "Gizlilik",
"resources": "Kaynaklar",
"legal": "Yasal",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "Зроблено з 💜 у Microsoft",
"opensInNewTab": "відкривається в новій вкладці",
"ask": "Запитання & Відповіді",
"collab": "Співпраця",
"community": "Спільнота",
"discuss": "Обговорити",
"watch": "Переглянути",
"blog": "Блог",
"privacy": "Приватність",
"resources": "Ресурси",
"legal": "Правова інформація",
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/content/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
"madeWithLove": "由 Microsoft 倾情打造 💜",
"opensInNewTab": "在新标签页中打开",
"ask": "问 & 答",
"collab": "协作",
"community": "社区",
"discuss": "讨论",
"watch": "观看",
"blog": "博客",
"privacy": "隐私",
"resources": "资源",
"legal": "法律信息",
Expand Down
38 changes: 38 additions & 0 deletions src/frontend/tests/unit/custom-components.vitest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,44 @@ describe('custom Astro component render coverage', () => {
expect(html).not.toContain('h=1000');
});

it('renders footer community links with platform names', async () => {
const translations: Record<string, string> = {
'footer.community': 'Community',
'footer.blog': 'Blog',
'footer.collab': 'Collaborate',
'footer.discuss': 'Discuss',
'footer.watch': 'Watch',
};
const t = ((key: string) => translations[key] ?? key) as ((key: string) => string) & {
dir: () => 'ltr';
};
t.dir = () => 'ltr';

const html = normalizeHtml(
await renderComponent(FooterLinks, {
locals: { t },
})
);

for (const label of [
'X (Twitter)',
'BlueSky',
'GitHub',
'Discord',
'Reddit',
'YouTube',
'Twitch',
'Blog',
]) {
expect(html).toContain(label);
}

expect(html).not.toContain('Follow');
expect(html).not.toContain('Collaborate');
expect(html).not.toContain('Discuss');
expect(html).not.toContain('Watch');
});

it('hides footer community links on localized 404 pages', async () => {
const html = normalizeHtml(
await renderComponent(FooterLinks, {
Expand Down
Loading