Skip to content

Commit 266d121

Browse files
committed
Fix public driver thumbnail deplolyment
1 parent 4983b81 commit 266d121

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

.github/workflows/deploy-astro.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,24 @@ jobs:
1515
- name: Set up Node.js
1616
uses: actions/setup-node@v3
1717
with:
18-
node-version: '18'
18+
node-version: "18"
1919

2020
- name: Install dependencies
2121
run: npm install
2222

23+
- name: Copy driver thumbnails to public directory
24+
run: |
25+
mkdir -p public/images/drivers
26+
find src/content/docs -type f -name "*.webp" ! -path "*/images/*" | while read file; do
27+
# Extract manufacturer and driver from path
28+
# Path format: src/content/docs/category/manufacturer/driver/driver.webp
29+
manufacturer=$(echo "$file" | cut -d'/' -f5)
30+
driver=$(basename "$file" .webp)
31+
mkdir -p "public/images/drivers/$manufacturer"
32+
cp "$file" "public/images/drivers/$manufacturer/$driver.webp"
33+
echo "Copied: $file -> public/images/drivers/$manufacturer/$driver.webp"
34+
done
35+
2336
- name: Build Astro project
2437
run: npm run build
2538

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
dist/
33
# generated types
44
.astro/
5+
# public driver images
6+
public/images/drivers/*
57

68
# dependencies
79
node_modules/

.vscode/tasks.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Copy Thumbnails to Public",
6+
"type": "shell",
7+
"command": "mkdir -p public/images/drivers && find src/content/docs -type f -name '*.webp' ! -path '*/images/*' | while read file; do manufacturer=$(echo \"$file\" | cut -d'/' -f5); driver=$(basename \"$file\" .webp); mkdir -p \"public/images/drivers/$manufacturer\"; cp \"$file\" \"public/images/drivers/$manufacturer/$driver.webp\"; echo \"Copied: $file -> public/images/drivers/$manufacturer/$driver.webp\"; done",
8+
"problemMatcher": [],
9+
"presentation": {
10+
"reveal": "always",
11+
"panel": "new"
12+
}
13+
},
14+
{
15+
"label": "Build (with thumbnails)",
16+
"dependsOn": ["Copy Thumbnails to Public"],
17+
"dependsOrder": "sequence",
18+
"type": "shell",
19+
"command": "npm run build",
20+
"problemMatcher": [],
21+
"group": {
22+
"kind": "build",
23+
"isDefault": true
24+
}
25+
}
26+
]
27+
}

src/pages/[category]/[manufacturer].astro

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,12 @@ const driversByManufacturer = allDrivers.filter((driver) => {
9393
driversByManufacturer.map((driver) => {
9494
const driverPath = `/${slugify(driver.id.replace(/\.md$/, ""))}`;
9595

96-
// Construct path to co-located thumbnail
96+
// Construct path to thumbnail in public directory
9797
// driver.id is like "rotators/moon-lite/night-crawler-rotator-and-focuser/night-crawler-rotator-and-focuser.md"
9898
const driverParts = driver.id.split("/");
99-
const actualCategorySlug = driverParts[0]; // Get actual file location category
10099
const manufacturerSlug = driverParts[1]; // Get "moon-lite"
101100
const driverSlug = driverParts[2]; // Get "night-crawler-rotator-and-focuser"
102-
const thumbnailPath = `/src/content/docs/${actualCategorySlug}/${manufacturerSlug}/${driverSlug}/${driverSlug}.webp`;
101+
const thumbnailPath = `/images/drivers/${manufacturerSlug}/${driverSlug}.webp`;
103102

104103
return (
105104
<a href={driverPath} class="driver-box">

0 commit comments

Comments
 (0)