1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
---
import Layout from "@/layouts/Layout.astro";
import { getCollection, render } from "astro:content";
import { type GetStaticPaths } from "astro";
interface Props {
entry: any;
}
export const getStaticPaths: GetStaticPaths = async () => {
const entries = await getCollection("blog");
return entries.map((entry: any) => ({
params: { id: entry.id },
props: { entry },
}));
};
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(),
keywords: entry.data.tags || [],
author: {
"@type": "Person",
name: "Ariel Costas Guerrero",
},
publisher: {
"@type": "Person",
name: "Ariel Costas Guerrero",
url: "https://www.costas.dev",
image: {
"@type": "ImageObject",
url: "https://www.costas.dev/favicon.png",
},
},
};
---
<Layout title={entry.data.title} description={entry.data.description}>
<script
is:inline
type="application/ld+json"
slot="head-jsonld"
set:html={JSON.stringify(schema)}
/>
<h1>{entry.data.title}</h1>
<small>
Publicado el
<time datetime={entry.data.publishedAt.toISOString()}>
{formattedDate}
</time>
{entry.data.tags && entry.data.tags.length > 0 && (
<>
• Etiquetas:
<ul class="tags">
{entry.data.tags.map((tag: string) => (
<li><a href={`/blog/?tag=${encodeURIComponent(tag)}`}>{tag}</a></li>
))}
</ul>
</>
)}
</small>
<Content />
<p>
<a href="/blog/">Volver al blog</a>
</p>
</Layout>
<style lang="scss">
@use "../../styles/variables" as v;
@use "sass:color";
h1 {
font-size: 2.5rem;
font-weight: 700;
margin-bottom: 0.5rem;
line-height: 1.2;
}
small {
display: block;
margin-bottom: 1.5rem;
font-size: 0.95rem;
color: hsl(209, 20%, 50%);
}
time {
font-style: italic;
font-weight: 500;
}
.tags {
display: inline-flex;
flex-direction: row;
list-style: none;
margin: 0;
padding: 0;
gap: 0.5rem;
margin-left: 0.25rem;
}
.tags li {
display: inline;
}
.tags a {
display: inline-block;
padding: 0.25rem 0.625rem;
background-color: rgba(0, 153, 255, 0.1);
color: v.$accentDark;
border: 1px solid rgba(0, 102, 204, 0.2);
border-radius: 1.25rem;
font-size: 0.8rem;
font-weight: 500;
font-family: v.$monoFontStack;
text-decoration: none;
box-shadow: none !important;
&:hover {
background-color: rgba(0, 153, 255, 0.2);
border-color: v.$accent;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}
&:focus {
outline: 3px solid v.$accent;
outline-offset: 2px;
background-color: rgba(0, 153, 255, 0.2);
box-shadow: none !important;
}
}
</style>
|