From e3141794b95e534656427fadf0354435c62254d6 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Thu, 10 Apr 2025 21:42:41 +0200 Subject: Fix formatting --- src/pages/blog/index.astro | 116 +++++++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 52 deletions(-) (limited to 'src/pages/blog/index.astro') diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index e889706..68ad02e 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -1,69 +1,81 @@ --- 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(); + return b.data.publishedAt.getTime() - a.data.publishedAt.getTime(); }); + const groupedPosts = blogCollection.reduce( - (acc: Record, 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; - }, - {}, + (acc: Record, 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 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", - } + "@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", + }, }; - --- - - + +