Skip to content

Commit c1bbdeb

Browse files
committed
feat: update workspace configuration and improve localization handling
- Added `allowBuilds` for esbuild and sharp in `pnpm-workspace.yaml`. - Adjusted footer component to include spaces around the author's name. - Enhanced header component to utilize new localization functions for path generation. - Refactored language dropdown and picker components to use `getLocalizedPath`. - Updated navigation bar to use localized paths for links. - Implemented utility functions for route handling and localization in `utils.ts`. - Simplified middleware logic for locale handling and redirection. - Created a custom 404 page with animations and a user-friendly message. - Added a new CV page detailing professional experience and skills. - Removed outdated Spanish index page and integrated its content into the main index. - Introduced a privacy policy page outlining data handling practices. - Updated SEO configuration with the correct base URL.
1 parent 761d38e commit c1bbdeb

17 files changed

Lines changed: 1216 additions & 739 deletions

.github/workflows/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ jobs:
4848
env:
4949
GITHUB_TOKEN: ${{ secrets.PAT }}
5050
GIT_AUTHOR_NAME: 'GitHub Actions'
51-
GIT_AUTHOR_EMAIL: 'action@github.com'
51+
GIT_AUTHOR_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com'
5252
GIT_COMMITTER_NAME: 'GitHub Actions'
53-
GIT_COMMITTER_EMAIL: 'action@github.com'
53+
GIT_COMMITTER_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com'
5454
- name: Upload artifact
5555
uses: actions/upload-artifact@v7
5656
with:

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "module",
55
"version": "1.1.0",
66
"private": true,
7-
"packageManager": "pnpm@10.33.3",
7+
"packageManager": "pnpm@11.13.1",
88
"scripts": {
99
"dev": "astro dev",
1010
"start": "astro dev",
@@ -24,17 +24,17 @@
2424
},
2525
"homepage": "https://github.com/AlexTorresDev/alextrs.dev#readme",
2626
"dependencies": {
27-
"@astrojs/preact": "^5.1.2",
28-
"@astrojs/mdx": "5.0.4",
29-
"@astrojs/rss": "4.0.18",
30-
"@astrojs/sitemap": "3.7.2",
31-
"@lucide/astro": "^1.14.0",
32-
"preact": "^10.29.1",
33-
"preact-render-to-string": "^6.6.7",
34-
"@tailwindcss/vite": "4.2.4",
35-
"astro": "6.2.2",
36-
"tailwindcss": "4.2.4",
37-
"vite-plugin-pwa": "1.2.0"
27+
"@astrojs/preact": "^6.0.1",
28+
"@astrojs/mdx": "7.0.3",
29+
"@astrojs/rss": "4.0.19",
30+
"@astrojs/sitemap": "3.7.3",
31+
"@lucide/astro": "^1.24.0",
32+
"preact": "^10.29.7",
33+
"preact-render-to-string": "^6.7.0",
34+
"@tailwindcss/vite": "4.3.2",
35+
"astro": "7.0.9",
36+
"tailwindcss": "4.3.2",
37+
"vite-plugin-pwa": "1.3.0"
3838
},
3939
"devDependencies": {
4040
"standard": "17.1.2"

pnpm-lock.yaml

Lines changed: 1089 additions & 614 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
allowBuilds:
2+
esbuild: true
3+
sharp: true
14
onlyBuiltDependencies:
25
- '@tailwindcss/oxide'
36
- esbuild

src/components/Footer.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const t = useTranslations(lang)
1313
>
1414
<span class="text-sm text-neutral-500 sm:text-center dark:text-neutral-400">
1515
{t('footer.copyright-1')}
16-
<span class="font-bold">Alex Torres</span>
16+
<span class="font-bold"> Alex Torres </span>
1717
{t('footer.copyright-2')}
1818
</span>
1919
<Social inFooter />

src/components/Header/Header.astro

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
---
2-
import { getLangFromUrl, useTranslations } from '@/i18n/utils'
2+
import { getLangFromUrl, getLocalizedPath, getRouteWithoutLocale, useTranslations } from '@/i18n/utils'
33
44
import LanguageDropdown from './LanguageDropdown.jsx'
55
import Logo from './Logo.astro'
66
import ThemeSwitcher from './ThemeSwitcher.astro'
77
88
const lang = getLangFromUrl(Astro.url)
99
const t = useTranslations(lang)
10-
const pathname = Astro.url.pathname
11-
const route = pathname.split('/').filter(Boolean).slice(1).join('/')
12-
const currentPath = `/${lang}/${route}`
10+
const route = getRouteWithoutLocale(Astro.url)
11+
const currentPath = getLocalizedPath(lang, route)
1312
const navItems = [
14-
{ href: `/${lang}/`, label: t('nav.home') },
15-
{ href: `/${lang}/cv`, label: t('nav.cv') }
13+
{ href: getLocalizedPath(lang), label: t('nav.home') },
14+
{ href: getLocalizedPath(lang, 'cv'), label: t('nav.cv') }
1615
]
1716
---
1817

@@ -39,7 +38,7 @@ const navItems = [
3938
</svg>
4039
</label>
4140
<a
42-
href={`/${lang}`}
41+
href={getLocalizedPath(lang)}
4342
class="flex items-center space-x-3 rtl:space-x-reverse text-emerald-500"
4443
>
4544
<Logo />

src/components/Header/LanguageDropdown.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useEffect, useRef, useState } from "preact/hooks";
22
import { languages } from "@/i18n/ui";
3+
import { getLocalizedPath } from "@/i18n/utils";
34

45
const chevron = (
56
<svg
@@ -20,7 +21,7 @@ export default function LanguageDropdown({ currentLang, route }) {
2021
const [open, setOpen] = useState(false);
2122
const menuRef = useRef(null);
2223

23-
const getHref = (lang) => (route ? `/${lang}/${route}` : `/${lang}/`);
24+
const getHref = (lang) => getLocalizedPath(lang, route);
2425

2526
useEffect(() => {
2627
const onClick = (event) => {

src/components/Header/LanguagePicker.astro

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
---
2-
import { getLangFromUrl } from '@/i18n/utils'
2+
import { getLangFromUrl, getLocalizedPath, getRouteWithoutLocale } from '@/i18n/utils'
33
import { languages } from '@/i18n/ui'
44
55
const currentLang = getLangFromUrl(Astro.url)
6-
const pathname = Astro.url.pathname
7-
const route = pathname.split('/').filter(Boolean).slice(1).join('/')
8-
9-
const getHref = (lang: keyof typeof languages) =>
10-
route ? `/${lang}/${route}` : `/${lang}/`
6+
const route = getRouteWithoutLocale(Astro.url)
7+
const getHref = (lang: keyof typeof languages) => getLocalizedPath(lang, route)
118
---
129

1310
<nav aria-label="Cambiar idioma" class="hidden md:inline-flex flex-none">

src/components/Header/NavBar.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
2-
import { getLangFromUrl, useTranslations } from '@/i18n/utils'
2+
import { getLangFromUrl, getLocalizedPath, useTranslations } from '@/i18n/utils'
33
44
const lang = getLangFromUrl(Astro.url)
55
const t = useTranslations(lang)
66
---
77

88
<nav>
99
<ul>
10-
<li><a href={`/${lang}`}>{t('nav.home')}</a></li>
10+
<li><a href={getLocalizedPath(lang)}>{t('nav.home')}</a></li>
1111
<li>
12-
<a href={`/${lang}/privacy-policy`}>{t('nav.about')}</a>
12+
<a href={getLocalizedPath(lang, 'cv')}>{t('nav.cv')}</a>
1313
</li>
1414
</ul>
1515
</nav>

src/i18n/utils.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@ export function getLangFromUrl(url: URL) {
66
return defaultLang
77
}
88

9+
export function getRouteWithoutLocale(url: URL) {
10+
const segments = url.pathname.split('/').filter(Boolean)
11+
const [maybeLang, ...rest] = segments
12+
13+
if (maybeLang in ui) {
14+
return rest.join('/')
15+
}
16+
17+
return segments.join('/')
18+
}
19+
20+
export function getLocalizedPath(lang: keyof typeof ui, route = '') {
21+
const normalizedRoute = route.replace(/^\/+|\/+$/g, '')
22+
23+
if (lang === defaultLang) {
24+
return normalizedRoute ? `/${normalizedRoute}` : '/'
25+
}
26+
27+
return normalizedRoute ? `/${lang}/${normalizedRoute}` : `/${lang}/`
28+
}
29+
930
export function useTranslations(lang: keyof typeof ui) {
1031
return function t(key: keyof (typeof ui)[typeof defaultLang]) {
1132
return ui[lang][key] || ui[defaultLang][key]

0 commit comments

Comments
 (0)