- Small fix to support subdirectories for asset folders
+21
-2
packages/cli/src/lib/atproto.ts
+21
-2
packages/cli/src/lib/atproto.ts
···
190
190
contentDir: string,
191
191
): Promise<string | null> {
192
192
// Try multiple resolution strategies
193
-
const filename = path.basename(ogImage);
194
193
195
194
// 1. If imagesDir is specified, look there
196
195
if (imagesDir) {
197
-
const imagePath = path.join(imagesDir, filename);
196
+
// Get the base name of the images directory (e.g., "blog-images" from "public/blog-images")
197
+
const imagesDirBaseName = path.basename(imagesDir);
198
+
199
+
// Check if ogImage contains the images directory name and extract the relative path
200
+
// e.g., "/blog-images/other/file.png" with imagesDirBaseName "blog-images" -> "other/file.png"
201
+
const imagesDirIndex = ogImage.indexOf(imagesDirBaseName);
202
+
let relativePath: string;
203
+
204
+
if (imagesDirIndex !== -1) {
205
+
// Extract everything after "blog-images/"
206
+
const afterImagesDir = ogImage.substring(
207
+
imagesDirIndex + imagesDirBaseName.length,
208
+
);
209
+
// Remove leading slash if present
210
+
relativePath = afterImagesDir.replace(/^[/\\]/, "");
211
+
} else {
212
+
// Fall back to just the filename
213
+
relativePath = path.basename(ogImage);
214
+
}
215
+
216
+
const imagePath = path.join(imagesDir, relativePath);
198
217
if (await fileExists(imagePath)) {
199
218
const stat = await fs.stat(imagePath);
200
219
if (stat.size > 0) {
History
1 round
0 comments
stevedylan.dev
submitted
#0
1 commit
expand
collapse
fix: asset subdirectories
1/1 success
expand
collapse
expand 0 comments
pull request successfully merged