Fixed translations for news items - amended data structure. Added locale to news posts. Added filter by locale for news display.
This commit is contained in:
parent
0053ee71bc
commit
5bb47caa95
|
|
@ -4,13 +4,14 @@ import { Icon } from "astro-icon/components";
|
||||||
|
|
||||||
import { createTranslator } from "../i18n/index.ts";
|
import { createTranslator } from "../i18n/index.ts";
|
||||||
const tl = createTranslator(Astro.currentLocale);
|
const tl = createTranslator(Astro.currentLocale);
|
||||||
|
const currentLocale = Astro.currentLocale;
|
||||||
---
|
---
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between px-8 md:px-0 md:py-4">
|
<div class="flex justify-between px-8 md:px-0 md:py-4">
|
||||||
<div class="border-l-4 border-colorPrimary pl-4">
|
<div class="border-l-4 border-colorPrimary pl-4">
|
||||||
<p class="font-secondary text-colorPrimary font-bold leading-none py-2 text-2xl md:text-lg">
|
<p class="font-secondary text-colorPrimary font-bold leading-none py-2 text-2xl md:text-lg">
|
||||||
<a href="/">{tl("nav.logo_line1")}<br/>{tl("nav.logo_line2")}</a>
|
<a href={`/${currentLocale}`}>{tl("nav.logo_line1")}<br/>{tl("nav.logo_line2")}</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<nav
|
<nav
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ const countryName = regionNames.of(data.data.country);
|
||||||
<p class="font-light text-2xl mb-8">
|
<p class="font-light text-2xl mb-8">
|
||||||
{data.data.city}, {countryName}<br />({nicedate}):
|
{data.data.city}, {countryName}<br />({nicedate}):
|
||||||
</p>
|
</p>
|
||||||
<h3 class="text-2xl font-bold mb-8"><a href={`/news/${data.id}`}>{data.data.title}</a></h3>
|
<h3 class="text-2xl font-bold mb-8"><a href={`/${locale}/news/${data.id}`}>{data.data.title}</a></h3>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Image
|
<Image
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
---
|
---
|
||||||
import { getCollection, getEntry } from "astro:content";
|
import { getCollection, getEntry } from "astro:content";
|
||||||
import NewsCard from "../cards/NewsCard.astro";
|
import NewsCard from "../cards/NewsCard.astro";
|
||||||
const newsItems = await getCollection("news");
|
const newsItems = await getCollection("news", (post)=>{
|
||||||
|
//Filter by locale
|
||||||
|
const currentLocale = Astro.currentLocale;
|
||||||
|
return post.data.locale == currentLocale
|
||||||
|
});
|
||||||
|
|
||||||
import { createTranslator, t } from '../../i18n';
|
import { createTranslator, t } from '../../i18n';
|
||||||
const tl = createTranslator(Astro.currentLocale);
|
const tl = createTranslator(Astro.currentLocale);
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@ import { glob, file } from 'astro/loaders';
|
||||||
import { z } from 'astro/zod';
|
import { z } from 'astro/zod';
|
||||||
|
|
||||||
const news = defineCollection({
|
const news = defineCollection({
|
||||||
loader: glob({ pattern: "**/*.md", base: "./src/data/news" }),
|
loader: glob({ pattern: "**/*.md", base: "./src/content/news" }),
|
||||||
schema: z.object({
|
schema: z.object({
|
||||||
|
locale: z.string(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
date: z.date(),
|
date: z.date(),
|
||||||
place: z.string().optional(),
|
place: z.string().optional(),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
locale: en
|
||||||
|
title: 'A news article in english'
|
||||||
|
date: 2025-09-18
|
||||||
|
slug: 2025-09-18-a-news-article-in-english
|
||||||
|
place: The basement
|
||||||
|
city: Cota
|
||||||
|
country: CO
|
||||||
|
thumbnail: https://ik.imagekit.io/crpy/tr:w-600/Condecoracion-JBP-congreso-18-sep-2025_-15-scaled.jpg
|
||||||
|
---
|
||||||
|
Some dummy news content in here
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
---
|
---
|
||||||
|
locale: es
|
||||||
title: 'La democracia se vistió de gala: el Congreso de Colombia honra al Dr. José Benjamín Pérez Matos'
|
title: 'La democracia se vistió de gala: el Congreso de Colombia honra al Dr. José Benjamín Pérez Matos'
|
||||||
date: 2025-09-18
|
date: 2025-09-18
|
||||||
slug: 2025-09-18-la-democracia-se-vistio-de-gala
|
slug: 2025-09-18-la-democracia-se-vistio-de-gala
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
---
|
---
|
||||||
|
locale: es
|
||||||
title: 'Un nuevo hijo para Jacareí: el homenaje al Dr. José Benjamín Pérez Matos'
|
title: 'Un nuevo hijo para Jacareí: el homenaje al Dr. José Benjamín Pérez Matos'
|
||||||
date: 2025-08-29
|
date: 2025-08-29
|
||||||
slug: 2025-08-29-un-nuevo-hijo-para-jacarei
|
slug: 2025-08-29-un-nuevo-hijo-para-jacarei
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
---
|
---
|
||||||
|
locale: es
|
||||||
title: 'Condecoración al Dr. José Benjamín Pérez Matos en el Congreso de Colombia'
|
title: 'Condecoración al Dr. José Benjamín Pérez Matos en el Congreso de Colombia'
|
||||||
date: 2025-05-08
|
date: 2025-05-08
|
||||||
slug: 2025-05-08-condecoracion-al-dr-jose-benjamin-perez-matos
|
slug: 2025-05-08-condecoracion-al-dr-jose-benjamin-perez-matos
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
---
|
---
|
||||||
|
locale: es
|
||||||
title: 'San Juan Chamula, corazón indígena, congrega a miles en jornada espiritual'
|
title: 'San Juan Chamula, corazón indígena, congrega a miles en jornada espiritual'
|
||||||
date: 2024-10-04
|
date: 2024-10-04
|
||||||
slug: 2024-10-04-san-juan-chamula-corazon-indigena
|
slug: 2024-10-04-san-juan-chamula-corazon-indigena
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
export const infoboxes = [
|
|
||||||
{
|
|
||||||
title: 'Diplomacia Pública y\nproyección Internacional',
|
|
||||||
copy: 'Construcción consciente de vínculos éticos, culturales y estratégicos entre pueblos',
|
|
||||||
bgColor: '#CBA16A',
|
|
||||||
sizeTitle: 'text-2xl',
|
|
||||||
titleColor: 'text-[#1F5349]',
|
|
||||||
textColor: 'text-[#003421]',
|
|
||||||
sizeText: 'text-xl',
|
|
||||||
buttonLabel: 'Leer más',
|
|
||||||
hasButton: true,
|
|
||||||
url:'#projection',
|
|
||||||
hasIcon: true,
|
|
||||||
// iconColor: 'text-[#1F5349]',
|
|
||||||
hasInput: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Programas y áreas\nde Acción',
|
|
||||||
copy: 'Cursos, seminarios y programas de formación dirigidos a líderes, profesionales, referentes.',
|
|
||||||
bgColor: '#003421',
|
|
||||||
sizeTitle: 'text-2xl',
|
|
||||||
titleColor: 'text-[#CBA16A]',
|
|
||||||
textColor: 'text-[#EDE9D9]',
|
|
||||||
sizeText: 'text-xl',
|
|
||||||
buttonLabel: 'Leer más',
|
|
||||||
bgImage: 'https://ik.imagekit.io/crpy/tr:o-20/dove.webp?updatedAt=1770966556158',
|
|
||||||
url:'#programs',
|
|
||||||
hasButton: true,
|
|
||||||
hasIcon: true,
|
|
||||||
// iconColor: 'text-[#CBA16A]',
|
|
||||||
hasInput: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Quiero postularme\ncomo Voluntario',
|
|
||||||
copy: 'Sumarse es asumir un compromiso con propósito',
|
|
||||||
bgColor: '#EBE6D2',
|
|
||||||
sizeTitle: 'text-2xl',
|
|
||||||
titleColor: 'text-[#CBA16A]',
|
|
||||||
textColor: 'text-[#003421]',
|
|
||||||
sizeText: 'text-xl',
|
|
||||||
buttonLabel: 'Registrarse',
|
|
||||||
hasButton: false,
|
|
||||||
hasIcon: true,
|
|
||||||
// iconColor: 'text-[#CBA16A]',
|
|
||||||
hasInput: true
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
// bg
|
|
||||||
// heading color
|
|
||||||
// text color
|
|
||||||
// hasButton = boolean
|
|
||||||
// hasInput = boolean
|
|
||||||
// bgImage
|
|
||||||
|
|
@ -11,7 +11,6 @@ import IdentitySection from "../../components/section/IdentitySection.astro";
|
||||||
import AuthoritySection from "../../components/section/AuthoritySection.astro";
|
import AuthoritySection from "../../components/section/AuthoritySection.astro";
|
||||||
import ProjectionSection from "../../components/section/ProjectionSection.astro";
|
import ProjectionSection from "../../components/section/ProjectionSection.astro";
|
||||||
|
|
||||||
import { infoboxes } from "../../data/content/infosection.js";
|
|
||||||
import ColorSection from "../../components/section/ColorSection.astro";
|
import ColorSection from "../../components/section/ColorSection.astro";
|
||||||
import TitleSection from "../../components/section/TitleSection.astro";
|
import TitleSection from "../../components/section/TitleSection.astro";
|
||||||
import GridSection from "../../components/section/GridSection.astro";
|
import GridSection from "../../components/section/GridSection.astro";
|
||||||
|
|
@ -51,7 +50,7 @@ const carouselImages3 = [
|
||||||
|
|
||||||
<HeroHome />
|
<HeroHome />
|
||||||
|
|
||||||
<InfoSection bgColor="bg-white" title="Construyendo el mundo soñado por los profetas: justicia y paz para Israel y toda la humanidad" data={infoboxes} />
|
<InfoSection bgColor="bg-white" title="Construyendo el mundo soñado por los profetas: justicia y paz para Israel y toda la humanidad" />
|
||||||
|
|
||||||
<CarouselSection class="object-cover" images={carouselImages3} />
|
<CarouselSection class="object-cover" images={carouselImages3} />
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
---
|
||||||
|
import { YouTube } from 'astro-embed';
|
||||||
|
import MainLayout from "../../../layouts/MainLayout.astro";
|
||||||
|
import Header from "../../../components/Header.astro";
|
||||||
|
import CarouselSection from "../../../components/section/CarouselSection.astro";
|
||||||
|
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';
|
||||||
|
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, locale: post.data.locale },
|
||||||
|
props: { post },
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
// 2. For your template, you can get the entry directly from the prop
|
||||||
|
const { post } = Astro.props;
|
||||||
|
const { Content } = await render(post);
|
||||||
|
---
|
||||||
|
|
||||||
|
<MainLayout>
|
||||||
|
<div class="container mx-auto py-16">
|
||||||
|
<Header />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<TitleSection title={post.data.title} />
|
||||||
|
|
||||||
|
<div class="container mx-auto">
|
||||||
|
{post.data.gallery && <CarouselSection images={post.data.gallery} />}
|
||||||
|
<div class="grid md:grid-cols-10">
|
||||||
|
<div class="md:col-span-7 bg-white p-8 md:p-20 prose-p:mb-4 text-[#003421]">
|
||||||
|
<Content />
|
||||||
|
</div>
|
||||||
|
<div class="md:col-span-3 bg-tertiary md:sticky top-0 h-fit">
|
||||||
|
{ post.data.youtube && (
|
||||||
|
<YouTube id={post.data.youtube} />
|
||||||
|
|
||||||
|
)}
|
||||||
|
|
||||||
|
{post.data.gallery && (
|
||||||
|
post.data.gallery.map(galleryImage => (
|
||||||
|
<Image src={galleryImage.image} alt={galleryImage.text} />
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</MainLayout>
|
||||||
|
|
||||||
|
<FooterSection />
|
||||||
Loading…
Reference in New Issue