Skip to content

Commit 81fcf26

Browse files
authored
Display photos from Glass (#679)
1 parent 1ee9eaa commit 81fcf26

File tree

7 files changed

+151
-6
lines changed

7 files changed

+151
-6
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"check-links": "lychee --config .lychee.toml ."
2222
},
2323
"dependencies": {
24+
"@ascorbic/feed-loader": "^2.0.1",
2425
"@astrojs/check": "^0.9.6",
2526
"@astrojs/db": "0.18.3",
2627
"@astrojs/markdown-remark": "^6.3.10",

pnpm-lock.yaml

Lines changed: 41 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/PhotoFeed.astro

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
import { getCollection } from "astro:content";
3+
4+
const LIMIT = 12;
5+
6+
const entries = await getCollection("photos");
7+
const limitedEntries = entries.slice(0, LIMIT);
8+
9+
const photos = limitedEntries.map((entry) => entry.data);
10+
---
11+
12+
<ul class="photo-feed">
13+
{
14+
photos.map((photo) => (
15+
<li>
16+
<a href={photo.url}>
17+
<img src={photo.image?.url} alt={photo.title} />
18+
</a>
19+
</li>
20+
))
21+
}
22+
<li class="see-all">
23+
<a href="https://glass.photo/evadecker">See all photos</a>
24+
</li>
25+
</ul>
26+
27+
<style>
28+
.photo-feed {
29+
list-style: none;
30+
display: flex;
31+
gap: var(--space-xs);
32+
padding-inline: var(--space-xl);
33+
padding-block: var(--space-2xs) var(--space-l);
34+
margin: 0;
35+
overflow-x: auto;
36+
scroll-snap-type: x mandatory;
37+
scroll-padding: var(--space-xl);
38+
scrollbar-width: thin;
39+
}
40+
41+
li {
42+
display: inline-block;
43+
padding: 0;
44+
flex-shrink: 0;
45+
scroll-snap-align: start;
46+
view-timeline-name: --photo;
47+
view-timeline-axis: inline;
48+
}
49+
50+
a {
51+
display: block;
52+
height: 220px;
53+
width: auto;
54+
}
55+
56+
img {
57+
display: block;
58+
height: 100%;
59+
width: auto;
60+
object-fit: cover;
61+
background-color: var(--gray-3);
62+
}
63+
64+
.see-all a {
65+
display: flex;
66+
align-items: center;
67+
justify-content: center;
68+
padding-inline: var(--space-2xl);
69+
background-color: var(--gray-3);
70+
transition: background-color, color, font-weight, text-decoration;
71+
transition-duration: 0.2s;
72+
transition-timing-function: ease-in-out;
73+
74+
@media (hover: hover) {
75+
&:hover {
76+
background-color: var(--gray-4);
77+
}
78+
}
79+
}
80+
</style>

src/components/WorkList.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ const { items } = Astro.props;
221221
width: 100%;
222222

223223
img {
224-
background-color: var(--gray-4);
224+
background-color: var(--gray-3);
225225
display: block;
226226
aspect-ratio: 1.91 / 1;
227227
border-radius: var(--radius-xs);

src/content.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineCollection, z } from "astro:content";
2+
import { feedLoader } from "@ascorbic/feed-loader";
23
import { glob } from "astro/loaders";
34

45
export const collections = {
@@ -89,4 +90,10 @@ export const collections = {
8990
date: z.date(),
9091
}),
9192
}),
93+
94+
photos: defineCollection({
95+
loader: feedLoader({
96+
url: "https://glass.photo/evadecker/rss",
97+
}),
98+
}),
9299
};

src/pages/index.astro

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { getCollection } from "astro:content";
33
import WorkList from "src/components/WorkList.astro";
44
import Center from "../components/Center.astro";
5+
import PhotoFeed from "../components/PhotoFeed.astro";
56
import Synth from "../components/Synth/Synth.astro";
67
import BaseLayout from "../layouts/BaseLayout.astro";
78
@@ -49,10 +50,16 @@ const feed = work
4950
</div>
5051
</section>
5152
<section class="work">
52-
<h2 class="visuallyhidden">Work</h2>
53+
<h2>Projects</h2>
5354
<WorkList items={feed} />
5455
</section>
5556
</Center>
57+
<section class="photos">
58+
<Center>
59+
<h2>Latest photos</h2>
60+
</Center>
61+
<PhotoFeed />
62+
</section>
5663
</BaseLayout>
5764

5865
<script>
@@ -165,7 +172,17 @@ const feed = work
165172
}
166173
}
167174

175+
h2 {
176+
font-size: var(--step-1);
177+
margin-block-end: var(--space-m);
178+
}
179+
168180
.work {
169181
padding-block: var(--space-2xl);
170182
}
183+
184+
.photos {
185+
width: 100%;
186+
padding-block-end: var(--space-2xl);
187+
}
171188
</style>

src/styles/base.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
:root {
22
interpolate-size: allow-keywords;
3+
color-scheme: light dark;
34
}
45

56
html {
@@ -21,11 +22,13 @@ body {
2122
line-height: var(--line-height-body);
2223
text-rendering: optimizelegibility;
2324
font-synthesis: none;
25+
color-scheme: light;
2426
}
2527

2628
body.dark {
2729
-webkit-font-smoothing: antialiased;
2830
-moz-osx-font-smoothing: grayscale;
31+
color-scheme: dark;
2932
}
3033

3134
::selection {

0 commit comments

Comments
 (0)