aboutsummaryrefslogtreecommitdiff
path: root/src/pages/blog.astro
diff options
context:
space:
mode:
authorAriel Costas Guerrero <94913521+arielcostas@users.noreply.github.com>2024-05-04 01:05:04 +0200
committerAriel Costas Guerrero <94913521+arielcostas@users.noreply.github.com>2024-05-04 13:34:10 +0200
commitfe7c149811f2e20c055ad0375aff05d29491efb4 (patch)
tree8df0652a35cca0f9c8fcb5fb90648fef2f8415b4 /src/pages/blog.astro
parent3de434508e0b609dea1ce8dca94ef1b708e61d61 (diff)
Rebuild the site in Astro
Add licence Update site name in header to match README.md Add missing metadescription, opengraph and link to RSS Update Astro configuration to include sitemap integration with priority and changefreq settings New post
Diffstat (limited to 'src/pages/blog.astro')
-rw-r--r--src/pages/blog.astro72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/pages/blog.astro b/src/pages/blog.astro
new file mode 100644
index 0000000..e533fb6
--- /dev/null
+++ b/src/pages/blog.astro
@@ -0,0 +1,72 @@
+---
+import { getCollection } from "astro:content";
+import Layout from "../layouts/Layout.astro";
+
+const blogCollection = (await getCollection("blog")).sort((a, b) => {
+ return b.data.publishedAt.getTime() - a.data.publishedAt.getTime();
+});
+
+const groupedPosts = blogCollection.reduce(
+ (acc: Record<string, any[]>, post) => {
+ const year = post.data.publishedAt.getFullYear();
+ const month = post.data.publishedAt.getMonth() + 1;
+ const key = `${year}-${month}`;
+ if (!acc[key]) {
+ acc[key] = [];
+ }
+ acc[key].push(post);
+ return acc;
+ },
+ {},
+);
+
+function humaniseDate(date: Date) {
+ const result = date.toLocaleDateString("es-ES", {
+ month: "long",
+ year: "numeric",
+ });
+ return result.charAt(0).toUpperCase() + result.slice(1);
+}
+
+const schema = {
+ "@context": "https://schema.org",
+ "@type": "Blog",
+ "headline": "Blog de Ariel Costas",
+ "description": "En este blog encontrarás artículos sobre desarrollo, tecnología y otras temáticas que pueda querer compartir. Disclaimer de siempre: las opiniones son mías, y no representan a ninguna empresa o institución.",
+ "publisher": {
+ "@type": "Person",
+ "name": "Ariel Costas",
+ },
+ "author": {
+ "@type": "Person",
+ "name": "Ariel Costas",
+ }
+};
+---
+
+<Layout title="Blog" description="Artículos sobre desarrollo, tecnología y otras temáticas que pueda querer compartir.">
+ <script type="application/ld+json" slot="head-jsonld" set:html={JSON.stringify(schema)}></script>
+
+ <h1>Blog de Ariel Costas</h1>
+
+ <p>
+ En este blog encontrarás artículos sobre desarrollo, tecnología y otras
+ temáticas que pueda querer compartir. Disclaimer de siempre: las
+ opiniones son mías, y no representan a ninguna empresa o institución.
+ </p>
+
+ {
+ Object.entries(groupedPosts).map(([key, posts]) => (
+ <section>
+ <h2>{humaniseDate(new Date(key))}</h2>
+ <ul>
+ {posts.map((post) => (
+ <li>
+ <a href={`/blog/${post.slug}`}>{post.data.title}</a>
+ </li>
+ ))}
+ </ul>
+ </section>
+ ))
+ }
+</Layout>