diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/LallansIssue.astro | 8 | ||||
| -rw-r--r-- | src/components/LallansIssueContributions.astro | 6 | ||||
| -rw-r--r-- | src/components/LallansIssuesGallery.astro | 9 | ||||
| -rw-r--r-- | src/components/Navbar.astro | 11 | ||||
| -rw-r--r-- | src/components/Scotsoun.astro | 6 | ||||
| -rw-r--r-- | src/components/ScotsounCdGallery.astro | 9 | ||||
| -rw-r--r-- | src/components/SwitchLanguageLink.astro | 7 |
7 files changed, 19 insertions, 37 deletions
diff --git a/src/components/LallansIssue.astro b/src/components/LallansIssue.astro index a07d345..690e96c 100644 --- a/src/components/LallansIssue.astro +++ b/src/components/LallansIssue.astro @@ -1,19 +1,19 @@ --- import translate from '$i18n/translate'; import tSite from '$i18n/translations/site'; +import getLocaleFromPath from '$lib/getLocaleFromPath'; import relativePath from '$lib/relativePath'; import type LallansIssue from '$types/LallansIssue'; -import type Locale from '$types/Locale'; import LallansIssueContributions from './LallansIssueContributions.astro'; import LallansIssueContributors from './LallansIssueContributors.astro'; import PayPalButtons from './PayPalButtons.astro'; interface Props { issue: LallansIssue; - locale: Locale; } -const { issue, locale } = Astro.props; +const { issue } = Astro.props; +const locale = getLocaleFromPath(Astro.url.pathname); const t = translate(locale); --- @@ -36,7 +36,7 @@ const t = translate(locale); <section> { 'contributions' in issue ? ( - <LallansIssueContributions contributions={issue.contributions} locale={locale} /> + <LallansIssueContributions contributions={issue.contributions} /> ) : ( 'contributors' in issue && <LallansIssueContributors contributors={issue.contributors} /> ) diff --git a/src/components/LallansIssueContributions.astro b/src/components/LallansIssueContributions.astro index 425f66a..9cf46da 100644 --- a/src/components/LallansIssueContributions.astro +++ b/src/components/LallansIssueContributions.astro @@ -1,15 +1,15 @@ --- import translate from '$i18n/translate'; import tSite from '$i18n/translations/site'; +import getLocaleFromPath from '$lib/getLocaleFromPath'; import type { Contribution } from '$types/LallansIssue'; -import type Locale from '$types/Locale'; interface Props { contributions: Contribution[]; - locale: Locale; } -const { contributions, locale } = Astro.props; +const { contributions } = Astro.props; +const locale = getLocaleFromPath(Astro.url.pathname); const t = translate(locale); --- diff --git a/src/components/LallansIssuesGallery.astro b/src/components/LallansIssuesGallery.astro index c784156..f3db9b3 100644 --- a/src/components/LallansIssuesGallery.astro +++ b/src/components/LallansIssuesGallery.astro @@ -1,13 +1,8 @@ --- import { getAllLallansIssues } from '$data/lallans'; -import type Locale from '$types/Locale'; - -interface Props { - locale: Locale; -} - -const { locale } = Astro.props; +import getLocaleFromPath from '$lib/getLocaleFromPath'; +const locale = getLocaleFromPath(Astro.url.pathname); const issues = await getAllLallansIssues(); --- diff --git a/src/components/Navbar.astro b/src/components/Navbar.astro index 45cf96b..c4e31b2 100644 --- a/src/components/Navbar.astro +++ b/src/components/Navbar.astro @@ -1,16 +1,11 @@ --- -import type Locale from '$types/Locale'; import Breadcrumbs from './Breadcrumbs.astro'; import SwitchLanguageLink from './SwitchLanguageLink.astro'; import tSite from '$i18n/translations/site'; import translate from '$i18n/translate'; +import getLocaleFromPath from '$lib/getLocaleFromPath'; -interface Props { - locale: Locale; -} - -const { locale } = Astro.props; - +const locale = getLocaleFromPath(Astro.url.pathname); const t = translate(locale); --- @@ -20,6 +15,6 @@ const t = translate(locale); {t(tSite, { key: 'scots-leid-associe' })} </a> </p> - <SwitchLanguageLink currentLocale={locale} /> + <SwitchLanguageLink /> <Breadcrumbs /> </nav> diff --git a/src/components/Scotsoun.astro b/src/components/Scotsoun.astro index 1491ebc..a0600d1 100644 --- a/src/components/Scotsoun.astro +++ b/src/components/Scotsoun.astro @@ -2,17 +2,17 @@ import translate from '$i18n/translate'; import tSite from '$i18n/translations/site'; import tComponent from '$i18n/translations/components/scotsoun'; -import type Locale from '$types/Locale'; import type Scotsoun from '$types/Scotsoun'; import PayPalButtons from './PayPalButtons.astro'; import relativePath from '$lib/relativePath'; +import getLocaleFromPath from '$lib/getLocaleFromPath'; interface Props { - locale: Locale; scotsoun: Scotsoun; } -const { locale, scotsoun } = Astro.props; +const { scotsoun } = Astro.props; +const locale = getLocaleFromPath(Astro.url.pathname); const t = translate(locale); --- diff --git a/src/components/ScotsounCdGallery.astro b/src/components/ScotsounCdGallery.astro index 6f6c794..0a8cd92 100644 --- a/src/components/ScotsounCdGallery.astro +++ b/src/components/ScotsounCdGallery.astro @@ -1,13 +1,8 @@ --- import { getAllScotsoun } from '$data/scotsoun'; -import type Locale from '$types/Locale'; - -interface Props { - locale: Locale; -} - -const { locale } = Astro.props; +import getLocaleFromPath from '$lib/getLocaleFromPath'; +const locale = getLocaleFromPath(Astro.url.pathname); const scotsoun = await getAllScotsoun(); --- diff --git a/src/components/SwitchLanguageLink.astro b/src/components/SwitchLanguageLink.astro index 96dd538..62de1ba 100644 --- a/src/components/SwitchLanguageLink.astro +++ b/src/components/SwitchLanguageLink.astro @@ -3,13 +3,10 @@ import tPage from '$i18n/translations/components/languageLinks'; import tSite from '$i18n/translations/site'; import translate from '$i18n/translate'; import type Locale from '$types/Locale'; - -interface Props { - currentLocale: Locale; -} +import getLocaleFromPath from '$lib/getLocaleFromPath'; // This logic assumes that there are exactly two locales. -const { currentLocale } = Astro.props; +const currentLocale = getLocaleFromPath(Astro.url.pathname); const otherLocale: Locale = currentLocale === 'sco' ? 'en-GB' : 'sco'; const currentPath = Astro.url.pathname; const currentLocaleInPath = new RegExp(`(?<=^/)(${currentLocale}/)?`); |
