diff options
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/blog.astro | 72 | ||||
| -rw-r--r-- | src/pages/blog.xml.js | 19 | ||||
| -rw-r--r-- | src/pages/blog/[slug].astro | 59 |
3 files changed, 0 insertions, 150 deletions
diff --git a/src/pages/blog.astro b/src/pages/blog.astro deleted file mode 100644 index e533fb6..0000000 --- a/src/pages/blog.astro +++ /dev/null @@ -1,72 +0,0 @@ ---- -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> diff --git a/src/pages/blog.xml.js b/src/pages/blog.xml.js deleted file mode 100644 index ec8d424..0000000 --- a/src/pages/blog.xml.js +++ /dev/null @@ -1,19 +0,0 @@ -import rss from '@astrojs/rss'; -import { getCollection } from 'astro:content'; - - -export async function GET(context) { - const collection = await getCollection('blog'); - - return rss({ - title: "Blog de Ariel Costas", - description: "Artículos del blog de Ariel Costas", - site: context.site, - items: collection.map((post) => ({ - title: post.data.title, - link: `${context.site}blog/${post.slug}`, - description: post.data.metaDescription, - pubDate: post.data.publishedAt - })) - }) -}
\ No newline at end of file diff --git a/src/pages/blog/[slug].astro b/src/pages/blog/[slug].astro deleted file mode 100644 index f9ceec1..0000000 --- a/src/pages/blog/[slug].astro +++ /dev/null @@ -1,59 +0,0 @@ ---- -import type { GetStaticPaths } from "astro"; -import Layout from "../../layouts/Layout.astro"; -import { getCollection } from "astro:content"; - -export const getStaticPaths = (async () => { - const entries = await getCollection("blog"); - return entries.map((entry) => ({ - params: { slug: entry.slug }, - props: { entry }, - })); -}) satisfies GetStaticPaths; - -const { entry } = Astro.props; -const { Content } = await entry.render(); - -const formattedDate = new Date(entry.data.publishedAt).toLocaleDateString( - "es-ES", - { - year: "numeric", - month: "long", - day: "numeric", - weekday: "long", - }, -); - -const schema = { - "@context": "https://schema.org", - "@type": "BlogPosting", - headline: entry.data.title, - datePublished: entry.data.publishedAt.toISOString(), - author: { - "@type": "Person", - name: "Ariel Costas Guerrero", - }, - publisher: { - "@type": "Person", - name: "Ariel Costas Guerrero", - logo: { - "@type": "ImageObject", - url: "https://www.costas.dev/favicon.png", - }, - }, -}; ---- - -<Layout title={entry.data.title} description={entry.data.metaDescription}> - <script type="application/ld+json" slot="head-jsonld" set:html={JSON.stringify(schema)}></script> - - <h1>{entry.data.title}</h1> - <small> - Publicado el - <time datetime={entry.data.publishedAt.toISOString()}> - {formattedDate} - </time> - </small> - - <Content /> -</Layout> |
