refactor: centralize external links configuration
All checks were successful
/ deploy (push) Successful in 1s

- Create external-links.ts with all external URLs in one place
- Add locale-aware functions for wiki and CFP links
- Update nav.tsx and landing-page.tsx to use centralized config
- Remove duplicate URL definitions across components
This commit is contained in:
Dariusz Niemczyk 2025-08-27 18:22:00 +02:00
parent 8a629c3de8
commit 7bceaab551
No known key found for this signature in database
3 changed files with 50 additions and 11 deletions

View file

@ -7,6 +7,7 @@ import dynamic from 'next/dynamic';
import { jgs7, oxanium } from '@/fonts';
import { Lang } from '@/i18n/locales';
import { Translations } from "@/i18n/translations";
import { getWikiUrl, getCfpScheduleUrl, getEmailUrl } from '@/lib/external-links';
import { cn } from "@/lib/utils";
import Link from 'next/link';
import { ReactElement, useEffect, useRef } from "react";
@ -174,7 +175,7 @@ export default function LandingPage(
return (
<div>
<MainpageNav t={t} />
<MainpageNav t={t} currentLocale={currentLocale} />
<main className="flex flex-col min-h-screen grid-gap-10 gap-10 pb-12">
<section id="hero" className="h-screen relative overflow-hidden dark:bg-black light:bg-white ">
@ -190,7 +191,7 @@ export default function LandingPage(
<div className='flex flex-col space-y-4 items-center justify-center m-auto'>
<div className='flex flex-row gap-4'>
<Button className={`${oxanium.className} text-xl uppercase cursor-pointer`}>
<Link href={`https://cfp.cebula.camp/camp-2025/locale/set?locale=${currentLocale}&next=/camp-2025/schedule/`} className="flex items-center gap-2">
<Link href={getCfpScheduleUrl(currentLocale)} className="flex items-center gap-2">
<svg
className="w-5 h-5"
fill="none"
@ -208,7 +209,7 @@ export default function LandingPage(
</Link>
</Button>
<Button className={`${oxanium.className} text-xl uppercase cursor-pointer`}>
<Link href="https://wiki.cebula.camp/pl/home" target="_blank" rel="noopener noreferrer" className="flex items-center gap-2">
<Link href={getWikiUrl(currentLocale)} target="_blank" rel="noopener noreferrer" className="flex items-center gap-2">
<svg
className="w-5 h-5"
fill="none"
@ -291,7 +292,7 @@ export default function LandingPage(
</p>
</div>
<Button className={`${oxanium.className} text-xl uppercase cursor-pointer`} size="lg">
<Link href={`https://cfp.cebula.camp/camp-2025/locale/set?locale=${currentLocale}&next=/camp-2025/schedule/`}>
<Link href={getCfpScheduleUrl(currentLocale)}>
{t.contribute.agenda.viewButton}
</Link>
</Button>
@ -312,7 +313,7 @@ export default function LandingPage(
</section>
<section>
<Subheading>{t.faq.accesibility.title}</Subheading>
<TextWrapper><p>{t.faq.accesibility.description} <a href="mailto:orga@cebula.camp">{t.contact.email}</a></p></TextWrapper>
<TextWrapper><p>{t.faq.accesibility.description} <a href={getEmailUrl()}>{t.contact.email}</a></p></TextWrapper>
</section>
<section>
<Subheading>{t.faq.food.title}</Subheading>
@ -329,7 +330,7 @@ export default function LandingPage(
<TextWrapper><p>
<a className='hover:text-primary' href={`/${currentLocale}/pages/privacy`}>📜 {t.faq.documents.privacyPolicy}</a></p></TextWrapper>
<TextWrapper><p>
<a className='hover:text-primary' href="https://wiki.cebula.camp/pl/home" target="_blank" rel="noopener noreferrer">📚 {t.faq.documents.wiki}</a></p></TextWrapper>
<a className='hover:text-primary' href={getWikiUrl(currentLocale)} target="_blank" rel="noopener noreferrer">📚 {t.faq.documents.wiki}</a></p></TextWrapper>
</section>
</>
</NewSection>
@ -342,7 +343,7 @@ export default function LandingPage(
<section>
<TextWrapper><p>{t.contact.details.line1}</p></TextWrapper>
<br />
<TextWrapper><p>📬 <a href={`mailto:${t.contact.email}`}>{t.contact.email}</a> {t.contact.details.line2}</p></TextWrapper>
<TextWrapper><p>📬 <a href={getEmailUrl()}>{t.contact.email}</a> {t.contact.details.line2}</p></TextWrapper>
<br />
<TextWrapper><p>{t.contact.details.line3}</p></TextWrapper>
<br />

View file

@ -1,5 +1,7 @@
"use client"
import { type translations } from "@/i18n/translations"
import { Lang } from '@/i18n/locales'
import { getWikiUrl } from '@/lib/external-links'
import { cn } from "@/lib/utils"
import ScrollSpy from 'react-scrollspy-navigation'
import { MobileNav } from "./mobile-nav"
@ -15,15 +17,16 @@ const linksOrder: Array<keyof (typeof translations.pl)["nav"]> = [
'contact'
]
const externalLinks: Record<string, string> = {
'wiki': 'https://wiki.cebula.camp/pl/home'
}
export function MainpageNav({
t,
currentLocale = 'pl' as Lang
}: {
t: typeof translations.pl
currentLocale?: Lang
}) {
const externalLinks: Record<string, string> = {
'wiki': getWikiUrl(currentLocale)
}
return (
<NavContainer title={t.nav.title}>

35
src/lib/external-links.ts Normal file
View file

@ -0,0 +1,35 @@
import { Lang } from '@/i18n/locales'
export const EXTERNAL_URLS = {
email: 'orga@cebula.camp',
} as const
export function getWikiUrl(locale: Lang): string {
return `https://wiki.cebula.camp/${locale}/home`
}
export function getCfpScheduleUrl(locale: Lang): string {
return `https://cfp.cebula.camp/camp-2025/locale/set?locale=${locale}&next=/camp-2025/schedule/`
}
export function getCfpUrl(locale: Lang): string {
return `https://cfp.cebula.camp/camp-2025/cfp`
}
export function getCfpArtUrl(locale: Lang): string {
return `https://cfp.cebula.camp/camp-2025-art/cfp`
}
export function getEmailUrl(): string {
return `mailto:${EXTERNAL_URLS.email}`
}
export function getExternalLinks(locale: Lang) {
return {
wiki: getWikiUrl(locale),
cfpSchedule: getCfpScheduleUrl(locale),
cfp: getCfpUrl(locale),
cfpArt: getCfpArtUrl(locale),
email: getEmailUrl(),
}
}