Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielviol committed Oct 21, 2024
1 parent ac63b33 commit 8cd6d42
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 26 deletions.
8 changes: 0 additions & 8 deletions .deco/blocks/collections%2Fblog%2Fposts%2F377b4d05ae7d.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
"post": {
"authors": [],
"categories": [
{
"name": "Direitos e Políticas",
"slug": "direitos-e-politicas"
},
{
"name": "Justiça",
"slug": "justiça"
},
{
"name": "Notícias",
"slug": "news"
Expand Down
7 changes: 6 additions & 1 deletion .deco/blocks/collections%2Fblog%2Fposts%2F9c87f3b4f229.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"__resolveType": "blog/loaders/Blogpost.ts",
"post": {
"authors": [],
"categories": [],
"categories": [
{
"name": "Notícias",
"slug": "news"
}
],
"extraProps": [],
"title": "Nota da ANTRA sobre a Importância da CEDAW e sua Relevância para a Pauta Trans",
"excerpt": "Nota da ANTRA sobre a Importância da CEDAW e sua Relevância para a Pauta Trans",
Expand Down
7 changes: 5 additions & 2 deletions .deco/blocks/pages-Noticias-464054.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@
"title": "Todas as notícias",
"allNews": {
"__resolveType": "blog/loaders/BlogpostList.ts",
"sortBy": "date_desc",
"slug": "news",
"count": 1
"sortBy": "date_desc"
},
"pagination": {
"page": 1,
"perPage": 5
}
},
{
Expand Down
3 changes: 1 addition & 2 deletions islands/all-news.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface Info {
export interface Props {
title: string;
info: Info;
allNews?: BlogPostListingPage;
allNews?: BlogPost[] | null;
pagination?: {
page?: number;
perPage?: number;
Expand All @@ -30,7 +30,6 @@ export default function AllNewsIsland(
pagination: { perPage, page: page + 1 },
},
});
console.log(allNews)
const [selectedTags, setSelectedTags] = useState<string[]>([]);

useEffect(() => {
Expand Down
25 changes: 13 additions & 12 deletions islands/featured-news.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface Props {
news: News[];
title: string;
info: Info;
allNews?: BlogPostListingPage;
pagination?: {
allNews: BlogPost[] | null;
pagination: {
page?: number;
perPage?: number;
};
Expand All @@ -41,7 +41,8 @@ export default function FeaturedNewsIsland({
news,
title,
info,
allNews
allNews,
pagination: { page = 1, perPage = 13 } = {}
}: Props) {
const [selectedTags, setSelectedTags] = useState<string[]>([]);

Expand All @@ -51,14 +52,14 @@ export default function FeaturedNewsIsland({
);
};

// const filteredNews =
// selectedTags.length === 0
// ? allNews
// : allNews?.posts?.filter((newsItem) =>
// selectedTags.some((tag) =>
// newsItem?.posts?.extraProps?.some((item) => item.value.includes(tag))
// )
// );
const filteredNews =
selectedTags.length === 0
? allNews
: allNews?.filter((newsItem) =>
selectedTags.some((tag) =>
newsItem?.extraProps?.some((item) => item.value.includes(tag))
)
);

return (
<>
Expand Down Expand Up @@ -155,7 +156,7 @@ export default function FeaturedNewsIsland({
</div>
</div>
</div>
<AllNewsIsland title={title} info={info} allNews={allNews} />
<AllNewsIsland title={title} info={info} allNews={filteredNews} />
</>
);
}
7 changes: 6 additions & 1 deletion sections/FeaturedNews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ export interface Props {
title: string;
info: Info;
allNews?: BlogPost[] | null;
pagination?: {
page?: number;
perPage?: number;
};
}

export default function FeaturedNews(
{ tags, mainNews, news, title, info, allNews }: Props,
{ tags, mainNews, news, title, info, allNews, pagination }: Props,
) {
return (
<>
Expand All @@ -40,6 +44,7 @@ export default function FeaturedNews(
title={title}
info={info}
allNews={allNews}
pagination={pagination}
/>
</>
);
Expand Down

0 comments on commit 8cd6d42

Please sign in to comment.