Skip to content

Commit 5e49a53

Browse files
committed
enable about page
1 parent 47f6230 commit 5e49a53

File tree

7 files changed

+41
-16
lines changed

7 files changed

+41
-16
lines changed

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"typescript.inlayHints.parameterNames.enabled": "all",
33
"editor.formatOnSave": false,
4-
"editor.defaultFormatter": "esbenp.prettier-vscode"
4+
"editor.defaultFormatter": "esbenp.prettier-vscode",
5+
"[astro]": { "editor.formatOnSave": true },
6+
"[typescript]": { "editor.formatOnSave": true },
57
}

src/components/Navbar.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ const translatePath = useTranslatedPath(lang);
5050
<li>
5151
<a href={translatePath("/posts", lang)}>{t("nav.posts")}</a>
5252
</li>
53-
<!-- <li>
53+
<li>
5454
<a href={translatePath("/acerca-de", lang)}>{t("nav.about")}</a>
5555
</li>
56+
<!--
5657
<li>
5758
<a href={translatePath("/contactar", lang)}>{t("nav.contact")}</a>
5859
</li> -->

src/content/config.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ const postsCollection = defineCollection({
2828
}),
2929
});
3030

31+
const pagesCollection = defineCollection({
32+
type: "content",
33+
schema: z.object({}),
34+
});
35+
3136
const categoriesCollection = defineCollection({
3237
type: "data",
3338
schema: z.object({
@@ -37,18 +42,15 @@ const categoriesCollection = defineCollection({
3742

3843
const authorsCollection = defineCollection({
3944
type: "data",
40-
schema:
41-
z.object({
42-
name: z.string(),
43-
surname: z.string().optional(),
44-
image: z.string(),
45-
email: z.string().optional(),
46-
socialMedia: z
47-
.array(
48-
z.object({ name: z.string(), icon: z.string(), link: z.string() }),
49-
)
50-
.optional(),
51-
}),
45+
schema: z.object({
46+
name: z.string(),
47+
surname: z.string().optional(),
48+
image: z.string(),
49+
email: z.string().optional(),
50+
socialMedia: z
51+
.array(z.object({ name: z.string(), icon: z.string(), link: z.string() }))
52+
.optional(),
53+
}),
5254
});
5355

5456
const publicationsCollection = defineCollection({
@@ -73,6 +75,7 @@ const publicationsCollection = defineCollection({
7375

7476
export const collections = {
7577
posts: postsCollection,
78+
pages: pagesCollection,
7679
authors: authorsCollection,
7780
publications: publicationsCollection,
7881
categories: categoriesCollection,

src/content/pages/en/about.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
---
3+
Shit

src/content/pages/es/acerca-de.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
---
3+
Caca

src/i18n/utils.ts

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

9+
export function getUrlWithoutLang(url: URL): string {
10+
const pathParts = url.pathname.split("/").filter(Boolean);
11+
const lang = pathParts.length > 0 ? pathParts[0] : undefined;
12+
if (lang && lang in ui) {
13+
return pathParts.slice(1).join("/");
14+
}
15+
return url.pathname.startsWith("/") ? url.pathname.slice(1) : url.pathname;
16+
}
17+
918
export function useTranslations(lang: keyof typeof ui) {
1019
return function t(key: keyof (typeof ui)[typeof defaultLang]) {
1120
// @ts-ignore

src/pages/[...lang]/[...about].astro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
---
22
import Layout from "../../layouts/Layout.astro";
3+
import { getEntry } from "astro:content";
34
import { languages, defaultLang } from "../../i18n/ui";
45
import {
56
getLangFromUrl,
7+
getUrlWithoutLang,
68
useTranslatedPath,
79
useTranslations,
810
} from "../../i18n/utils";
911
1012
export function getStaticPaths() {
1113
return Object.keys(languages).map((lang) => {
1214
const translatePath = useTranslatedPath(lang as keyof typeof languages);
15+
let pipi = translatePath("acerca-de").split("/").pop();
1316
return {
1417
params: {
1518
lang: lang !== defaultLang ? lang : undefined,
@@ -20,8 +23,9 @@ export function getStaticPaths() {
2023
}
2124
2225
const lang = getLangFromUrl(Astro.url);
23-
26+
const slug = getUrlWithoutLang(Astro.url);
2427
const t = useTranslations((lang ?? defaultLang) as keyof typeof languages);
28+
const page = (await getEntry("pages", `${lang}/${slug}`))!;
2529
---
2630

27-
<Layout title={t("nav.contact")}>Hola</Layout>
31+
<Layout title={t("nav.about")}>{page.body}</Layout>

0 commit comments

Comments
 (0)