astro-blog-kit 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { BlogListProps } from "../../types";
|
|
3
|
+
import type { BlogPost } from "../../types";
|
|
4
|
+
import { getFeaturedImageUrl } from "../../utils/slug";
|
|
5
|
+
|
|
6
|
+
interface Props extends BlogListProps {}
|
|
7
|
+
|
|
8
|
+
const { posts, blogBase, dateLocale, t } = Astro.props;
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<div class="cards">
|
|
12
|
+
{posts.map((post: BlogPost) => {
|
|
13
|
+
const imgUrl = getFeaturedImageUrl(post);
|
|
14
|
+
return (
|
|
15
|
+
<article class="card">
|
|
16
|
+
<a href={`${blogBase}${post.slug}/`} class="card__link">
|
|
17
|
+
<div
|
|
18
|
+
class="card__bg"
|
|
19
|
+
style={imgUrl ? `background-image: url('${imgUrl}')` : ""}
|
|
20
|
+
>
|
|
21
|
+
{!imgUrl && (
|
|
22
|
+
<div class="card__no-image">
|
|
23
|
+
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
24
|
+
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
|
25
|
+
<circle cx="8.5" cy="8.5" r="1.5"/>
|
|
26
|
+
<path d="M21 15l-5-5L5 21"/>
|
|
27
|
+
</svg>
|
|
28
|
+
</div>
|
|
29
|
+
)}
|
|
30
|
+
<div class="card__overlay" />
|
|
31
|
+
<div class="card__content">
|
|
32
|
+
<time class="card__date">
|
|
33
|
+
{new Date(post.date).toLocaleDateString(dateLocale, {
|
|
34
|
+
year: "numeric",
|
|
35
|
+
month: "long",
|
|
36
|
+
day: "numeric",
|
|
37
|
+
})}
|
|
38
|
+
</time>
|
|
39
|
+
<h2 class="card__title" set:html={post.title.rendered} />
|
|
40
|
+
<div class="card__excerpt" set:html={post.excerpt.rendered} />
|
|
41
|
+
<span class="card__cta">{t.blog.btncta} →</span>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</a>
|
|
45
|
+
</article>
|
|
46
|
+
);
|
|
47
|
+
})}
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<style>
|
|
51
|
+
.cards {
|
|
52
|
+
display: grid;
|
|
53
|
+
grid-template-columns: 1fr;
|
|
54
|
+
gap: 1.5rem;
|
|
55
|
+
margin-bottom: 4rem;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@media (min-width: 640px) {
|
|
59
|
+
.cards {
|
|
60
|
+
grid-template-columns: repeat(2, 1fr);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@media (min-width: 1024px) {
|
|
65
|
+
.cards {
|
|
66
|
+
grid-template-columns: repeat(3, 1fr);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.card {
|
|
71
|
+
border-radius: 12px;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.card:hover {
|
|
77
|
+
transform: translateY(-6px);
|
|
78
|
+
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.card__link {
|
|
82
|
+
display: block;
|
|
83
|
+
height: 100%;
|
|
84
|
+
text-decoration: none;
|
|
85
|
+
color: inherit;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.card__bg {
|
|
89
|
+
position: relative;
|
|
90
|
+
height: 380px;
|
|
91
|
+
background-color: var(--color-surface);
|
|
92
|
+
background-size: cover;
|
|
93
|
+
background-position: center;
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: flex-end;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.card__no-image {
|
|
99
|
+
position: absolute;
|
|
100
|
+
inset: 0;
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
color: var(--color-muted);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.card__overlay {
|
|
108
|
+
position: absolute;
|
|
109
|
+
inset: 0;
|
|
110
|
+
background: linear-gradient(
|
|
111
|
+
to bottom,
|
|
112
|
+
transparent 0%,
|
|
113
|
+
rgba(0, 0, 0, 0.3) 40%,
|
|
114
|
+
rgba(0, 0, 0, 0.85) 100%
|
|
115
|
+
);
|
|
116
|
+
border-radius: 12px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.card__content {
|
|
120
|
+
position: relative;
|
|
121
|
+
z-index: 1;
|
|
122
|
+
padding: 1.75rem;
|
|
123
|
+
display: flex;
|
|
124
|
+
flex-direction: column;
|
|
125
|
+
gap: 0.5rem;
|
|
126
|
+
width: 100%;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.card__date {
|
|
130
|
+
font-size: 0.7rem;
|
|
131
|
+
font-weight: 700;
|
|
132
|
+
text-transform: uppercase;
|
|
133
|
+
letter-spacing: 0.12em;
|
|
134
|
+
color: rgba(255, 255, 255, 0.7);
|
|
135
|
+
font-family: var(--font-mono);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.card__title {
|
|
139
|
+
font-family: var(--font-heading);
|
|
140
|
+
font-size: 1.25rem;
|
|
141
|
+
font-weight: 700;
|
|
142
|
+
color: #ffffff;
|
|
143
|
+
line-height: 1.2;
|
|
144
|
+
margin: 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.card__excerpt {
|
|
148
|
+
font-size: 0.85rem;
|
|
149
|
+
color: rgba(255, 255, 255, 0.75);
|
|
150
|
+
line-height: 1.5;
|
|
151
|
+
display: -webkit-box;
|
|
152
|
+
-webkit-line-clamp: 2;
|
|
153
|
+
-webkit-box-orient: vertical;
|
|
154
|
+
overflow: hidden;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.card__excerpt :global(p) {
|
|
158
|
+
margin: 0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.card__cta {
|
|
162
|
+
font-size: 0.8rem;
|
|
163
|
+
font-weight: 700;
|
|
164
|
+
color: var(--color-accent);
|
|
165
|
+
display: inline-block;
|
|
166
|
+
margin-top: 0.5rem;
|
|
167
|
+
transition: transform 0.2s ease;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.card:hover .card__cta {
|
|
171
|
+
transform: translateX(4px);
|
|
172
|
+
}
|
|
173
|
+
</style>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { BlogListProps } from "../../types";
|
|
3
|
+
import type { BlogPost } from "../../types";
|
|
4
|
+
import BlogCard from "../BlogCard.astro";
|
|
5
|
+
|
|
6
|
+
interface Props extends BlogListProps {}
|
|
7
|
+
|
|
8
|
+
const { posts, blogBase, dateLocale, t } = Astro.props;
|
|
9
|
+
|
|
10
|
+
const featured = posts[0] as BlogPost | undefined;
|
|
11
|
+
const rest = posts.slice(1) as BlogPost[];
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<div class="featured">
|
|
15
|
+
|
|
16
|
+
{featured && (
|
|
17
|
+
<div class="featured__hero">
|
|
18
|
+
<BlogCard
|
|
19
|
+
post={featured}
|
|
20
|
+
blogBase={blogBase}
|
|
21
|
+
dateLocale={dateLocale}
|
|
22
|
+
ctaText={t.blog.btncta}
|
|
23
|
+
variant="featured"
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
)}
|
|
27
|
+
|
|
28
|
+
{rest.length > 0 && (
|
|
29
|
+
<div class="featured__grid">
|
|
30
|
+
{rest.map((post: BlogPost) => (
|
|
31
|
+
<BlogCard
|
|
32
|
+
post={post}
|
|
33
|
+
blogBase={blogBase}
|
|
34
|
+
dateLocale={dateLocale}
|
|
35
|
+
ctaText={t.blog.btncta}
|
|
36
|
+
variant="grid"
|
|
37
|
+
/>
|
|
38
|
+
))}
|
|
39
|
+
</div>
|
|
40
|
+
)}
|
|
41
|
+
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<style>
|
|
45
|
+
.featured {
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
gap: 2rem;
|
|
49
|
+
margin-bottom: 4rem;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.featured__hero {
|
|
53
|
+
width: 100%;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.featured__hero .blog-card--featured .blog-card__thumb {
|
|
57
|
+
aspect-ratio: 21 / 9;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.featured__grid {
|
|
61
|
+
display: grid;
|
|
62
|
+
grid-template-columns: 1fr;
|
|
63
|
+
gap: 1.5rem;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@media (min-width: 640px) {
|
|
67
|
+
.featured__grid {
|
|
68
|
+
grid-template-columns: repeat(2, 1fr);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@media (min-width: 1024px) {
|
|
73
|
+
.featured__grid {
|
|
74
|
+
grid-template-columns: repeat(3, 1fr);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</style>
|
package/package.json
CHANGED