-
- {post.data.gallery?.length ? ( ) : post.data.thumbnail ? ( ) : null}
-
-
-
-
-
-
-
-
- { post.data.youtube && (
-
- )}
-
- {post.data.gallery && (
- post.data.gallery.map(galleryImage => (
-
- ))
- )}
-
-
-
-
-
diff --git a/src/pages/news/[id].astro b/src/pages/[news_slug]/[id].astro
similarity index 90%
rename from src/pages/news/[id].astro
rename to src/pages/[news_slug]/[id].astro
index 5bede2c..ba3ae7b 100644
--- a/src/pages/news/[id].astro
+++ b/src/pages/[news_slug]/[id].astro
@@ -7,22 +7,27 @@ import { Image } from "@unpic/astro";
import { getCollection, render } from "astro:content";
import TitleSection from "../../components/section/TitleSection.astro";
import FooterSection from '../../components/section/FooterSection.astro';
+import { getLocalizedRoute } from '@/i18n';
export const prerender = true;
// 1. Generate a new path for every collection entry
export async function getStaticPaths() {
const posts = await getCollection("news");
return posts.map((post) => ({
- params: { id: post.id },
+ params: {
+ id: post.id,
+ news_slug: getLocalizedRoute('news', post.data.locale)
+ },
props: { post },
}));
}
+const { news_slug } = Astro.params;
const { post } = Astro.props;
const { Content } = await render(post);
console.log("astro site", Astro.site);
const baseUrl = Astro.site ?? "https://mk8nrc8p-4321.brs.devtunnels.ms";
-const pageUrl = new URL(`/es/news/${post.id}`, baseUrl).toString();
+const pageUrl = new URL(`/${post.data.locale}/${news_slug}/${post.id}`, baseUrl).toString();
---
diff --git a/src/pages/news/index.astro b/src/pages/[news_slug]/index.astro
similarity index 84%
rename from src/pages/news/index.astro
rename to src/pages/[news_slug]/index.astro
index f2a1e5b..269d6e2 100644
--- a/src/pages/news/index.astro
+++ b/src/pages/[news_slug]/index.astro
@@ -8,9 +8,18 @@ import FooterSection from "@/components/section/FooterSection.astro";
import NewsList from "@/components/cards/NewsList.astro";
-import { createTranslator, t } from '@/i18n';
+import { createTranslator, getLocalizedRoute, routeTranslations } from '@/i18n';
const tl = createTranslator(Astro.currentLocale);
+export function getStaticPaths() {
+ const locales = Object.keys(routeTranslations.news);
+ return locales.map((locale) => ({
+ params: {
+ news_slug: getLocalizedRoute('news', locale)
+ },
+ }));
+}
+
const newsItems = await getCollection("news", (post)=>{
const currentLocale = Astro.currentLocale;
return post.data.locale == currentLocale