From 373a4af4b1837b5e125401ad2f98daada0708306 Mon Sep 17 00:00:00 2001
From: juancmandev
Date: Wed, 31 Jul 2024 13:41:41 -0600
Subject: [PATCH] config i18n
---
src/components/footer.tsx | 9 +-
src/components/header.astro | 4 +-
src/components/navigation.tsx | 106 ++++++++++-----------
src/content/pages/about.mdx | 12 +--
src/content/pages/es/acerca-de.mdx | 22 +++++
src/content/pages/es/contacto.mdx | 36 +++++++
src/content/pages/es/recursos.mdx | 61 ++++++++++++
src/i18n/ui.ts | 16 ++++
src/i18n/utils.ts | 19 ++++
src/layouts/Layout.astro | 15 ++-
src/pages/404.astro | 7 +-
src/pages/[...slug].astro | 2 +-
src/pages/blog/[...slug].astro | 2 +-
src/pages/blog/index.astro | 2 +-
src/pages/es/[...slug].astro | 28 ++++++
src/pages/es/feed.xml.ts | 129 ++++++++++++++++++++++++++
src/pages/es/index.astro | 6 +-
src/pages/es/videos/[...slug].astro | 6 +-
src/pages/es/videos/index.astro | 2 +-
src/pages/{rss.xml.ts => feed.xml.ts} | 2 +-
src/pages/index.astro | 1 -
src/pages/microblog.astro | 1 -
src/pages/portfolio/[...slug].astro | 6 +-
src/pages/portfolio/index.astro | 2 +-
24 files changed, 400 insertions(+), 96 deletions(-)
create mode 100644 src/content/pages/es/acerca-de.mdx
create mode 100644 src/content/pages/es/contacto.mdx
create mode 100644 src/content/pages/es/recursos.mdx
create mode 100644 src/i18n/ui.ts
create mode 100644 src/i18n/utils.ts
create mode 100644 src/pages/es/[...slug].astro
create mode 100644 src/pages/es/feed.xml.ts
rename src/pages/{rss.xml.ts => feed.xml.ts} (97%)
diff --git a/src/components/footer.tsx b/src/components/footer.tsx
index 5e82f0e..6f0e1ca 100644
--- a/src/components/footer.tsx
+++ b/src/components/footer.tsx
@@ -47,7 +47,14 @@ export default function Footer(props: Props) {
variant="link"
className="flex flex-col justify-center"
>
-
+
RSS feed
diff --git a/src/components/header.astro b/src/components/header.astro
index c1624ac..e8447b9 100644
--- a/src/components/header.astro
+++ b/src/components/header.astro
@@ -21,7 +21,7 @@ const locales = {
top: "Arriba",
navigation: "Navevación",
},
-} as const;
+};
const { lang } = Astro.props;
---
@@ -34,7 +34,7 @@ const { lang } = Astro.props;
>
-
- Blog
- >
- ),
+ type: "blog",
+ icon: ,
+ },
+ { type: "portfolio", icon: },
+ {
+ type: "videos",
+ icon: ,
},
{
- to: "/portfolio",
- child: (
- <>
-
- Portfolio
- >
- ),
+ type: "microblog",
+ icon: ,
},
{
- to: "es/videos",
- child: (
- <>
-
- Videos
- >
- ),
+ type: "resources",
+ icon: ,
},
{
- to: "/microblog",
- child: (
- <>
-
- Microblog
- >
- ),
+ type: "about",
+ icon: ,
},
{
- to: "/resources",
- child: (
- <>
-
- Resources
- >
- ),
- },
- {
- to: "/about",
- child: (
- <>
-
- About
- >
- ),
- },
- {
- to: "/contact",
- child: (
- <>
-
- Contact
- >
- ),
+ type: "contact",
+ icon: ,
},
];
@@ -84,19 +47,46 @@ type Props = {
lang: "en" | "es";
};
+const locales = {
+ en: {
+ navigation: "Navigation",
+ blog: { label: "Blog", to: "/blog" },
+ portfolio: { label: "Portfolio", to: "/portfolio" },
+ videos: { label: "Videos", to: "/es/videos" },
+ microblog: { label: "Microblog", to: "/microblog" },
+ resources: { label: "Resources", to: "/resources" },
+ about: { label: "About", to: "/about" },
+ contact: { label: "Contact", to: "/contact" },
+ },
+ es: {
+ navigation: "Navegación",
+ blog: { label: "Blog", to: "/es/blog" },
+ portfolio: { label: "Portfolio", to: "/es/portfolio" },
+ videos: { label: "Videos", to: "/es/videos" },
+ microblog: { label: "Microblog", to: "/microblog" },
+ resources: { label: "Recursos", to: "/es/recursos" },
+ about: { label: "Acerca de", to: "/es/acerca-de" },
+ contact: { label: "Contacto", to: "/es/contacto" },
+ },
+} as const;
+
export default function Navigation(props: Props) {
+ const t = useTranslations(props.lang);
+ const translatePath = useTranslatedPath(props.lang);
+
return (
+
+ Este es mi website, un pedazo de Internet al que puedo
+ llamar hogar. Aquí comparto mi pasión por proyectos open
+ source y otros temas.
+
diff --git a/src/pages/es/videos/[...slug].astro b/src/pages/es/videos/[...slug].astro
index 63f00a2..2d65bc9 100644
--- a/src/pages/es/videos/[...slug].astro
+++ b/src/pages/es/videos/[...slug].astro
@@ -25,11 +25,7 @@ const { project } = Astro.props;
const { Content } = await project.render();
---
-
+
{project.data.title}
diff --git a/src/pages/es/videos/index.astro b/src/pages/es/videos/index.astro
index 2b79dda..4bbc2e4 100644
--- a/src/pages/es/videos/index.astro
+++ b/src/pages/es/videos/index.astro
@@ -16,7 +16,7 @@ const allVideos = await getCollection(
sortContentByDate(allVideos);
---
-
+
{pageData.title}
{pageData.description}
diff --git a/src/pages/rss.xml.ts b/src/pages/feed.xml.ts
similarity index 97%
rename from src/pages/rss.xml.ts
rename to src/pages/feed.xml.ts
index 3863d22..39d8c02 100644
--- a/src/pages/rss.xml.ts
+++ b/src/pages/feed.xml.ts
@@ -121,7 +121,7 @@ export async function GET(context: any) {
juancmandev
https://juancman.dev
`,
- ``,
+ ``,
].join(""),
items,
trailingSlash: false,
diff --git a/src/pages/index.astro b/src/pages/index.astro
index b592960..d36a6e8 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -18,7 +18,6 @@ const last3Projects = allProjects.slice(0, 3);
---
diff --git a/src/pages/microblog.astro b/src/pages/microblog.astro
index eb1ea10..beddb18 100644
--- a/src/pages/microblog.astro
+++ b/src/pages/microblog.astro
@@ -11,7 +11,6 @@ const data = await pb.collection("microblogs").getFullList({
---
diff --git a/src/pages/portfolio/[...slug].astro b/src/pages/portfolio/[...slug].astro
index 08715e1..a841e01 100644
--- a/src/pages/portfolio/[...slug].astro
+++ b/src/pages/portfolio/[...slug].astro
@@ -25,11 +25,7 @@ const { project } = Astro.props;
const { Content } = await project.render();
---
-
+
{project.data.title}
diff --git a/src/pages/portfolio/index.astro b/src/pages/portfolio/index.astro
index 9f37aef..5ce723e 100644
--- a/src/pages/portfolio/index.astro
+++ b/src/pages/portfolio/index.astro
@@ -16,7 +16,7 @@ const allProjects = await getCollection(
sortContentByDate(allProjects);
---
-
+
{pageData.title}
{pageData.description}