diff options
| author | Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> | 2024-12-23 14:13:29 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> | 2024-12-23 14:13:29 +0100 |
| commit | 3013f352570439832075bab19c9ae91ec6ab98ac (patch) | |
| tree | 37052258a5e4d5859ad9024f99cceb9a38047707 /src/pages | |
| parent | 16b7b327d43a3d3a2ab0b6317072136d7df69a3d (diff) | |
Update to astro 5
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/blog.astro | 3 | ||||
| -rw-r--r-- | src/pages/blog/[id].astro (renamed from src/pages/blog/[slug].astro) | 113 | ||||
| -rw-r--r-- | src/pages/index.astro | 2 |
3 files changed, 61 insertions, 57 deletions
diff --git a/src/pages/blog.astro b/src/pages/blog.astro index 4cfcea3..9d2d77b 100644 --- a/src/pages/blog.astro +++ b/src/pages/blog.astro @@ -38,6 +38,7 @@ const schema = { "name": "Ariel Costas",
}
};
+
---
<Layout title="Blog" description="Artículos sobre desarrollo, tecnología y otras temáticas que pueda querer compartir.">
@@ -58,7 +59,7 @@ const schema = { <ul>
{posts.map((post) => (
<li>
- <a href={`/blog/${post.slug}`}>{post.data.title}</a>
+ <a href={`/blog/${post.id}`}>{post.data.title}</a>
</li>
))}
</ul>
diff --git a/src/pages/blog/[slug].astro b/src/pages/blog/[id].astro index a1a0532..6488a04 100644 --- a/src/pages/blog/[slug].astro +++ b/src/pages/blog/[id].astro @@ -1,55 +1,58 @@ ----
-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>
+--- +import type { GetStaticPaths } from "astro"; +import Layout from "../../layouts/Layout.astro"; +import { getCollection, render } from "astro:content"; + +export const getStaticPaths = (async () => { + const entries = await getCollection("blog"); + return entries.map((entry) => ({ + params: { id: entry.id }, + props: { entry }, + })); +}) as GetStaticPaths; + +const { entry } = Astro.props; +const { Content } = await render(entry); +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> diff --git a/src/pages/index.astro b/src/pages/index.astro index 5d1c24d..e995a9d 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -57,7 +57,7 @@ const schema = { <time datetime={p.data.publishedAt.toISOString()}> {date} </time> - <a href={`/blog/${p.slug}`}>{p.data.title}</a> + <a href={`/blog/${p.id}`}>{p.data.title}</a> </li> ); }) |
