Skip to content

Commit 975608c

Browse files
committed
fix thumbnails
1 parent 9609a49 commit 975608c

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const config = {
2222
return resolve(this.dataDir, 'projects');
2323
},
2424

25+
// Directory containing static thumbnails
26+
get thumbnailsDir() {
27+
return resolve(this.dataDir, 'thumbnails');
28+
},
29+
2530
// Logging
2631
logLevel: process.env.LOG_LEVEL || 'info',
2732

src/routes/projects.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function formatProject(row) {
4242
location: row.location,
4343
center: { lat: row.center_lat, lon: row.center_lon },
4444
entryPhotoId: row.entry_photo_id,
45+
previewThumbnail: `/thumbnails/${row.slug}.webp`,
4546
photoCount: row.photo_count,
4647
};
4748
}

src/server.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ await fastify.register(fastifyStatic, {
3434
decorateReply: false,
3535
});
3636

37+
// Static files — project thumbnails ({slug}.webp in /data/thumbnails/)
38+
await fastify.register(fastifyStatic, {
39+
root: config.thumbnailsDir,
40+
prefix: '/api/v1/thumbnails/',
41+
decorateReply: false,
42+
});
43+
3744
// Initialize database on startup
3845
getIndexDb();
3946

0 commit comments

Comments
 (0)