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
149
150
151
152
153
154
155
156
157
|
---
import Date from "@components/organisms/Date.astro";
import RelativeTime from "@components/organisms/RelativeTime.astro";
import KeywordsList from "@components/organisms/KeywordsList.astro";
import { getFirstUserID, getLastUpdate } from "@lib/collection/helpers";
import type { MicroEntry } from "@lib/collection/schemas";
import { getRelativeTimeUnit } from "@utils/datetime";
interface Props {
micro: MicroEntry;
seeAll?: boolean;
}
const { micro, seeAll = false } = Astro.props;
const { id, data, rendered } = micro;
const { title, lang, keywords } = data;
const date = getLastUpdate(micro);
const user = await getFirstUserID(micro);
const display = user?.name ?? user?.email ?? user?.entity ?? "";
const [first, ...names] = display.split(/\s/);
const last = names.length > 0 ? names[names.length - 1] : "";
const little = ((first?.[0] ?? "") + (last?.[0] ?? "")).slice(0, 2);
---
<article
itemprop="blogPost"
itemscope
itemtype="https://schema.org/BlogPosting"
style={`--rows: ${seeAll ? 3 : 2};`}
>
<header>
<h3 class="title">
<a href={`/blog/read/${id}`} itemprop="headline name">{title}</a>
</h3>
<span class="profile_picture">{
user?.website ? <a href={user.website}>{little}</a> : (
<span>{little}</span>
)
}</span>
<div>
<span
itemprop="author"
itemscope
itemtype="https://schema.org/Person"
><span itemprop="alternateName">{first} {last}</span></span>
<span class="small"
>· <Date
{date}
locales={lang}
options={{ month: "short", day: "numeric" }}
itemprop="dateModified"
/> (<RelativeTime
{date}
locales={lang}
options={{
style: "short",
numeric: "auto",
}}
/>)</span>
</div>
<span class="lang mute">{lang}</span>
</header>
<div class="content small">
<div {lang} itemprop="articleBody text">
<Fragment set:html={rendered?.html} />
</div>
<footer>
<a href={`/blog/read/${id}`}>Ver mais...</a>
<div class="keywords"><KeywordsList {keywords} /></div>
</footer>
</div>
{
seeAll && (
<aside>
<small><a href="/blog/micro/1">Ver todos os microposts</a></small>
</aside>
)
}
</article>
<style>
article {
--rows: 2 border-radius: calc(var(--size-1) * 1em);
box-shadow: 0 0 calc(var(--size-1) * 1em) var(--color-light);
padding: calc(var(--size-4) * 1em);
display: grid;
grid-template-rows: repeat(var(--rows), auto);
grid-template-columns: calc(var(--size-9) * 1em) repeat(2, auto);
gap: calc(var(--size-1) * 1em);
& > header {
display: contents;
}
& > aside {
grid-row: 3 / 4;
grid-column: 1 / 4;
border-block-start: 1px solid #e7e7e7;
padding-block-start: calc(var(--size-1) * 1em);
}
}
.profile_picture {
grid-row: 1 / 3;
grid-column: 1 / 2;
& > * {
display: inline-grid;
place-content: center;
width: calc(var(--size-9) * 1em);
height: calc(var(--size-9) * 1em);
aspect-ratio: 1 / 1;
background-color: var(--color-active);
color: #fff;
font-weight: 950;
font-size: smaller;
/* border-radius: calc(infinity * 1px); */
border-radius: calc(var(--size-3) * 1em);
text-align: center;
text-transform: uppercase;
}
}
.title {
display: none;
}
.lang {
grid-row: 1/2;
grid-column: 3 / 4;
display: flex;
justify-content: flex-end;
align-items: baseline;
}
.content {
grid-row: 2/3;
grid-column: 2 / 4;
& > [lang] > :global(*:first-child) {
margin-block-start: 0;
}
& > [lang] > :global(*:last-child) {
margin-block-end: 0;
}
& > footer {
display: flex;
gap: 1em;
flex-wrap: wrap;
justify-content: space-between;
align-items: baseline;
}
}
.keywords {
margin-block-end: 0;
}
</style>
|