diff options
| author | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-08-18 21:28:17 +0100 |
|---|---|---|
| committer | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-08-18 21:38:16 +0100 |
| commit | a56344ea9aced15fc4d2932d48cb2efd7f452e94 (patch) | |
| tree | 12e58f6a0699291d4c5aea5c36d251db845f895b /src/components/Breadcrumbs.astro | |
| parent | 57b86c33a183e11652215f8588f728476f176fc5 (diff) | |
Pulls out nav module
Diffstat (limited to 'src/components/Breadcrumbs.astro')
| -rw-r--r-- | src/components/Breadcrumbs.astro | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/components/Breadcrumbs.astro b/src/components/Breadcrumbs.astro deleted file mode 100644 index 66f2a66..0000000 --- a/src/components/Breadcrumbs.astro +++ /dev/null @@ -1,33 +0,0 @@ ---- -import findAllIndicesOf from '$lib/findAllIndicesOf'; -import translate from '$i18n/translate'; -import tBreadcrumbs from '$i18n/translations/components/breadcrumbs'; -import type Locale from '$types/Locale'; -import locales from '$i18n/locales'; - -const path = Astro.url.pathname.replace(/(?<!\/)$/, '/'); -const localeInPath = new RegExp(`/(?<=^/)(${locales.join('|')})`); -const locale = path.match(localeInPath)?.[1] as Locale; -if (!locale) { - return; -} -const pathWithoutLocale = path.replace(new RegExp(`^/${locale}`), ''); -const slashIndices = findAllIndicesOf('/', pathWithoutLocale); -const parentRoutes = slashIndices.map((n) => pathWithoutLocale.slice(0, n + 1)).slice(0, -1); - -const t = translate(locale); ---- - -<ol class="breadcrumbs"> - { - parentRoutes.map((route) => { - return ( - <li> - <a class="link" href={`/${locale}${route}`}> - {t(tBreadcrumbs, { key: route })} - </a> - </li> - ); - }) - } -</ol> |
