Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 38 additions & 15 deletions src/components/EquipeTabs.astro
Original file line number Diff line number Diff line change
@@ -1,34 +1,57 @@
---
const {
ativos,
inativos,
lang = "pt",
layout = "pesquisador",
texts = {},
} = Astro.props;
import { getCollection } from "astro:content";
import IconSocial from "./IconSocial.astro";
// Types for members and social networks
type Rede = {
tipo: string;
url: string;
};
type Membro = {
slug?: string;
nome: string;
foto?: string;
redes?: Rede[];
cargo?: string;
descricao?: string;
contribuicao?: string;
};
// Typed props (infer from parent usage). ativos is an array of [categoria, membros[]]
const props = Astro.props as {
ativos?: Array<[string, Membro[]]>;
inativos?: Membro[];
lang?: string;
layout?: string;
texts?: Record<string, string>;
};
const ativos = props.ativos ?? [];
const inativos = props.inativos ?? [];
const lang = props.lang ?? "pt";
const layout = props.layout ?? "pesquisador";
const texts = props.texts ?? {};
const membrosCollection = await getCollection("membros");
const membrosDisponiveis = new Set(
membrosCollection
.filter((entry) => entry.id.endsWith(`.${lang}.mdx`))
.map((entry) =>
entry.id.split("/").pop().replace(/\.(pt|en|es)\.mdx$/, "")
)
.map((entry) => {
// pop() can be undefined; guard with optional chaining and fallback
const last = entry.id.split("/").pop()?.replace(/\.(pt|en|es)\.mdx$/, "") ?? "";
return last;
Comment on lines +42 to +43
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intermediate variable last is unnecessary. The code can be simplified to: return entry.id.split('/').pop()?.replace(/\\.(pt|en|es)\\.mdx$/, '') ?? '';

Suggested change
const last = entry.id.split("/").pop()?.replace(/\.(pt|en|es)\.mdx$/, "") ?? "";
return last;
return entry.id.split("/").pop()?.replace(/\.(pt|en|es)\.mdx$/, "") ?? "";

Copilot uses AI. Check for mistakes.
})
);
function getSlug(membro) {
function getSlug(membro: Membro): string {
return membro.slug?.trim() || membro.nome.toLowerCase().replace(/\s+/g, "-");
}
const categoriasTodas = Array.from(
new Set([
...ativos.map(([cat]) => cat),
...Object.keys(
Object.fromEntries(ativos.concat([["inativos", inativos]]))
),
...Object.keys(Object.fromEntries(ativos.concat([["inativos", inativos]]))),
])
);
---
Expand Down
12 changes: 7 additions & 5 deletions src/components/LanguageSelector.astro
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
---
import { routeTranslations } from "../i18n/routes";
import routeTranslations from "../i18n/routeTranslations";
import { getTranslatedPath } from "../utils/getTranslatedPath";
import type { SupportedLang } from "../i18n/routeTranslations";
import { getCollection } from "astro:content";
import IconLang from "../icons/iconLang.astro";
import IconLang from "../icons/iconLang.astro";
import { getTranslations } from "../utils/i18n";

const { lang = "pt" } = Astro.props;

const languages: { code: SupportedLang; label: string }[] = [
Expand All @@ -13,9 +15,9 @@ const languages: { code: SupportedLang; label: string }[] = [
];

const translations: Record<SupportedLang, any> = {
pt: (await import(`../i18n/locales/pt.json`)).default,
en: (await import(`../i18n/locales/en.json`)).default,
es: (await import(`../i18n/locales/es.json`)).default,
pt: getTranslations("pt"),
en: getTranslations("en"),
es: getTranslations("es"),
};

const pathParts = Astro.url.pathname.split("/").filter(Boolean);
Expand Down
12 changes: 8 additions & 4 deletions src/components/NoticiaPage.astro
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
---
import BaseLayout from '../layouts/BaseLayout.astro';
import { getEntry } from 'astro:content';
import { routeTranslations } from '../i18n/routes';
import routeTranslations from '../i18n/routeTranslations';
import type { SupportedLang } from '../types/lang';
import { getTranslations } from '../utils/i18n';

const { lang, slug } = Astro.props;
const { lang, slug } = Astro.props as { lang: SupportedLang; slug: string };
const locale = getTranslations(lang);

const post = await getEntry('noticias', slug.replace(`${routeTranslations['noticias'][lang]}/`, ''));
const noticiasRoute = routeTranslations['noticias'][lang as SupportedLang];
const post = await getEntry('noticias', slug.replace(`${noticiasRoute}/`, ''));

if (!post) throw new Error(`Notícia não encontrada: ${slug}`);

const { title, date, image } = post.data;
const { Content } = await post.render();
---

<BaseLayout lang={lang} titulo={title} descricao="" texts={{}}>
<BaseLayout lang={lang} titulo={title} descricao={locale.descricao} texts={locale.texts}>
<article class="prose max-w-3xl mx-auto py-10">
<h1>{title}</h1>
<p class="text-sm text-gray-500">{new Date(date).toLocaleDateString()}</p>
Expand Down
9 changes: 6 additions & 3 deletions src/components/NoticiasListPage.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
import BaseLayout from '../layouts/BaseLayout.astro';
import NoticiasSection from './NoticiasSection.astro';
import { getCollection } from 'astro:content';
import { getTranslations } from '../utils/i18n';
import type { SupportedLang } from '../types/lang';

const { lang } = Astro.props;
const { lang } = Astro.props as { lang: SupportedLang };
const locale = getTranslations(lang);

const allNoticias = await getCollection('noticias');

const noticias = allNoticias
.filter(post => post.data.lang === lang)
.sort((a, b) => b.data.date.getTime() - a.data.date.getTime());

const tituloPagina = lang === 'en' ? 'News' : lang === 'es' ? 'Noticias' : 'Notícias';
const tituloPagina = locale.texts.header.noticias || 'Notícias';
---

<BaseLayout lang={lang} titulo={tituloPagina} descricao="" texts={{}}>
<BaseLayout lang={lang} titulo={tituloPagina} descricao={locale.descricao} texts={locale.texts}>
<NoticiasSection noticias={noticias} lang={lang} />
</BaseLayout>
12 changes: 2 additions & 10 deletions src/components/SearchModal.astro
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
---
export function getStaticPaths() {
return [
{ params: { lang: 'pt' } },
{ params: { lang: 'en' } },
{ params: { lang: 'es' } }
];
}

const { lang } = Astro.params;
const { texts } = Astro.props;
import Search from "astro-pagefind/components/Search";
---

Expand All @@ -21,7 +13,7 @@ import Search from "astro-pagefind/components/Search";
<!-- ✅ Botão de fechar "X" -->
<label for="search-modal" class="absolute top-3 right-3 cursor-pointer text-lg font-bold">✖</label>

<h3 id="search-title" class="font-bold text-lg mb-4 text-primary">Buscar</h3>
<h3 id="search-title" class="font-bold text-lg mb-4 text-primary">{texts.header.buscar}</h3>

<!-- ✅ Componente de busca Pagefind mais translúcido -->
<div class="search-wrapper">
Expand Down
Loading