diff --git a/src/components/PostExcerpt.vue b/src/components/PostExcerpt.vue index 60a49274..ee6f0f5a 100644 --- a/src/components/PostExcerpt.vue +++ b/src/components/PostExcerpt.vue @@ -1,62 +1,33 @@ @@ -71,7 +42,7 @@ function formatDate(date: Date) {
+
...
{{ t("Seguir leyendo") }}
diff --git a/src/components/PostTranslationLink.astro b/src/components/PostTranslationLink.astro
index dea7d2a4..536e832d 100644
--- a/src/components/PostTranslationLink.astro
+++ b/src/components/PostTranslationLink.astro
@@ -2,7 +2,7 @@
import { getEntry } from "astro:content"
import type { CollectionEntry } from "astro:content"
import { getAbsoluteLocaleUrl } from "astro:i18n"
-import { getPostUrl } from "@/ts/functions"
+import { getPostUrlParts } from "@/ts/functions"
import { displayLanguages } from "@/i18n/ui"
type Translation = NonNullable<
@@ -26,7 +26,7 @@ const translationLabel = displayLanguages[translation.short]
class="capitalize"
href={getAbsoluteLocaleUrl(
translation.short,
- "/blog/" + getPostUrl(post).join("/"),
+ "/blog/" + getPostUrlParts(post).join("/"),
)}
>
{translationLabel}
diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro
index 7c5e1620..882cf5c0 100644
--- a/src/pages/blog/[...slug].astro
+++ b/src/pages/blog/[...slug].astro
@@ -4,7 +4,7 @@ import { getCollection, getEntry, render } from "astro:content"
import { Image } from "astro:assets"
import HtmlLayout from "@/layouts/html.astro"
import { getLangFromUrl, useTranslations } from "@/i18n/utils"
-import { postReadableDate } from "@/ts/functions"
+import { getPostUrlParts, postReadableDate } from "@/ts/functions"
import PostTag from "@/components/PostTag.vue"
import PostReactions from "@/components/PostReactions.vue"
import PostTranslationLink from "@/components/PostTranslationLink.astro"
@@ -12,19 +12,8 @@ import PostTranslationLink from "@/components/PostTranslationLink.astro"
export const getStaticPaths = (async () => {
const posts = await getCollection("posts", (post) => !post.id.includes("/"))
- function getPostUrl(post: {
- id: string
- data: { date: Date }
- }): [string, string, string] {
- const year = post.data.date.getFullYear().toString()
- const month = (post.data.date.getMonth() + 1).toString().padStart(2, "0")
- const slug = post.id.replace(/\d{4}-\d{2}-\d{2}-/, "")
-
- return [year, month, slug]
- }
-
return posts.map((post) => ({
- params: { slug: getPostUrl(post).join("/") },
+ params: { slug: getPostUrlParts(post).join("/") },
props: { post },
}))
}) satisfies GetStaticPaths
diff --git a/src/pages/en/blog/[...slug].astro b/src/pages/en/blog/[...slug].astro
index d64dc860..592eef14 100644
--- a/src/pages/en/blog/[...slug].astro
+++ b/src/pages/en/blog/[...slug].astro
@@ -2,7 +2,7 @@
import type { GetStaticPaths } from "astro"
import { getCollection } from "astro:content"
import BlogPost from "@/pages/blog/[...slug].astro"
-import { getPostUrl } from "@/ts/functions"
+import { getPostUrlParts } from "@/ts/functions"
export const getStaticPaths = (async () => {
const posts = await getCollection(
@@ -11,7 +11,7 @@ export const getStaticPaths = (async () => {
)
return posts.map((post) => ({
- params: { slug: getPostUrl(post).join("/") },
+ params: { slug: getPostUrlParts(post).join("/") },
props: { post },
}))
}) satisfies GetStaticPaths
diff --git a/src/ts/functions.ts b/src/ts/functions.ts
index ce8a0a5f..71a7de74 100644
--- a/src/ts/functions.ts
+++ b/src/ts/functions.ts
@@ -36,7 +36,7 @@ export function postReadableDate(lang: typeof languages[number], date: Date) {
return `${month} ${day}, ${year}`
}
-export function getPostUrl(post: {
+export function getPostUrlParts(post: {
id: string
data: { date: Date }
}): [string, string, string] {