Skip to content

Commit

Permalink
Update topics to categories
Browse files Browse the repository at this point in the history
  • Loading branch information
tcasaniv committed May 21, 2024
1 parent 805931c commit 49552df
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 66 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions src/layouts/BlogPost.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Header from "../components/Header.astro";
import Footer from "../components/Footer.astro";
import FormattedDate from "../components/FormattedDate.astro";
import AuthorList from "../components/AuthorList.astro";
import TopicList from "../components/TopicList.astro";
import CategorieList from "../components/CategorieList.astro";
import { Image } from "astro:assets";
import { ViewTransitions } from "astro:transitions";
import EmojiReactions from "../components/backend-services/EmojiReactions.astro";
Expand All @@ -20,7 +20,7 @@ const {
updatedDate,
heroImage,
authors,
topics,
categories,
} = Astro.props;
---

Expand Down Expand Up @@ -55,10 +55,10 @@ const {
<footer>
<EmojiReactions id={id} />
{
topics.length > 0 && (
categories.length > 0 && (
<>
<h2>Temas</h2>
<TopicList topics={topics} />
<h2>Categorías</h2>
<CategorieList categories={categories} />
</>
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/404.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Layout from "../layouts/Page.astro";
---

<Layout
title="Temas"
description="Una visión general de todos los temas en este blog."
title="Error 404"
description="Página no encontrada."
>
<h1>404 - no encontrado :(</h1>
<div class="not-prose">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blog/[...page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const { page } = Astro.props;
<h1>Blog</h1>
<p>
Buscar entradas del blog por {" "}
<a href="/topics" class="text-link no-underline"> tema</a>.
<a href="/categories" class="text-link no-underline"> categoría</a>.
</p>
{
!!import.meta.env.SECRET_APPWRITE_API_KEY && (
Expand Down
44 changes: 44 additions & 0 deletions src/pages/categories/[...slug].astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
import PostList from "../../components/PostList.astro";
import Layout from "../../layouts/Page.astro";
import { type CollectionEntry, getCollection } from "astro:content";
export async function getStaticPaths() {
const categories = await getCollection("categorie");
return categories
.filter((categorie) => (categorie.slug as string) !== "uncategorized")
.map((categorie) => ({
params: { slug: categorie.slug },
props: categorie,
}));
}
type Props = CollectionEntry<"categorie">;
const categorie = Astro.props;
const { Content } = await categorie.render();
const posts = await getCollection("blog");
const categoriePosts = posts
.filter((post) => post.data.draft === false)
.filter((post) => post.data.categories.includes(categorie.slug))
.sort((a, b) => a.data.pubDate.valueOf() - b.data.pubDate.valueOf());
const title = categorie.data.title;
const description = `Todas las entradas sobre ${title}`;
---

<Layout title={title} description={description}>
<section>
<h1>{categorie.data.title}</h1>
<Content />
{categoriePosts.length === 0 && <p>Aún no hay entradas.</p>}
{
categoriePosts.length > 0 && (
<>
<h2>Entradas sobre {categorie.data.title.toLowerCase()}</h2>
<PostList posts={categoriePosts} />
</>
)
}
</section>
</Layout>
12 changes: 12 additions & 0 deletions src/pages/categories/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
import Layout from "../../layouts/Page.astro";
import CategorieList from "../../components/CategorieList.astro";
---

<Layout
title="Categorías"
description="Una visión general de todos las categorías en este blog."
>
<h1>Todos las categorías de este blog</h1>
<CategorieList categories="all" />
</Layout>
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { getCollection } from "astro:content";
const posts = await getCollection("blog");
const uncategorizedPost = posts
.filter((post) => post.data.draft === false)
.filter((post) => post.data.topics.length === 0)
.filter((post) => post.data.categories.length === 0)
.sort((a, b) => a.data.pubDate.valueOf() - b.data.pubDate.valueOf());
const title = "Sin categoría";
const description = "Entradas de blog sin tema asociado";
const description = "Entradas de blog sin categoría asociada";
---

<Layout title={title} description={description}>
Expand Down
44 changes: 0 additions & 44 deletions src/pages/topics/[...slug].astro

This file was deleted.

12 changes: 0 additions & 12 deletions src/pages/topics/index.astro

This file was deleted.

0 comments on commit 49552df

Please sign in to comment.