-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.astro
125 lines (110 loc) · 2.38 KB
/
index.astro
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
---
import Metadata from '../components/metadata.astro'
import Logo from '../components/logo.astro'
const baseUrl = import.meta.env.PUBLIC_BASE_URL
const plants = Astro.fetchContent('../pages/*.md');
const newestFirst = (a, b) => new Date(b['last-updated']).valueOf() - new Date(a['last-updated']).valueOf()
---
<!DOCTYPE html>
<html lang="en">
<head>
<Metadata/>
<title>Spotted</title>
</head>
<body>
<div class="logo">
<Logo/>
</div>
<section>
{
plants.sort(newestFirst).map((plant) => (
<a class="plant" href={baseUrl + plant.url}>
<picture>
<source type="image/avif" srcset={`${baseUrl}/images/${plant.image}.avif`}/>
<source type="image/webp" srcset={`${baseUrl}/images/${plant.image}.webp`}/>
<img
src={`${baseUrl}/images/${plant.image}.png`}
alt={`Watercolor illustration of a ${plant.name}`}
/>
</picture>
<p>{plant.name}</p>
</a>
))
}
</section>
</body>
</html>
<style>
.logo
{
margin: 100px auto;
text-align: center;
}
section
{
display: grid;
gap: 2px;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
max-width: 1200px;
margin: 120px auto;
}
a.plant
{
aspect-ratio: 1 / 1;
box-sizing: border-box;
padding: 10px 16px;
border-radius: 2px;
text-decoration: none;
color: currentColor;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 1fr;;
background: transparent;
transition: all 0.2s ease-out;
}
a.plant:hover,
a.plant:focus
{
transition: all 0.3s ease;
transform: scale(1.01) translateY(-2px);
box-shadow: var(--shadow);
background: linear-gradient(0deg,
rgb(242, 253, 230) 0%,
rgb(248, 255, 241) 97%,
rgb(249, 255, 244) 99%);
outline: none;
z-index: 10;
}
a.plant > *
{
grid-column: 1;
grid-row: 1;
}
a.plant img
{
aspect-ratio: 1 / 1;
width: 100%;
height: 100%;
object-fit: contain;
mix-blend-mode: multiply;
-webkit-user-select: none;
user-select: none;
}
a.plant p
{
font-family: var(--font);
font-style: italic;
font-size: 1.2rem;
line-height: 1;
text-align: center;
align-self: flex-end;
z-index: 1;
margin: 0;
padding: 1.2rem 0;
text-shadow: 0 -2px 2px hsl(var(--light-green) / 1);
background: linear-gradient(180deg,
hsl(var(--light-green) / 0) 0%,
hsl(var(--light-green) / 0.8) 30%,
hsl(var(--light-green) / 1) 100%);
}
</style>