Skip to content

Commit d9ca80e

Browse files
committed
fix: run dev issue
1 parent f351208 commit d9ca80e

5 files changed

Lines changed: 30 additions & 20 deletions

File tree

package-lock.json

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

src/components/VideoCard.astro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@ interface Props {
1010
const { title, description, url, thumbnail, platform } = Astro.props;
1111
1212
const getEmbedUrl = (url: string, platform: string) => {
13-
if (platform === 'youtube') {
13+
// Normalize platform for comparison (trim and lowercase)
14+
const normalizedPlatform = platform?.trim().toLowerCase() || '';
15+
16+
if (normalizedPlatform === 'youtube') {
1417
const videoId = url.includes('youtu.be/')
1518
? url.split('youtu.be/')[1].split('?')[0]
1619
: url.split('v=')[1]?.split('&')[0];
1720
return videoId ? `https://www.youtube.com/embed/${videoId}` : url;
18-
} else if (platform === 'vimeo') {
21+
} else if (normalizedPlatform === 'vimeo') {
1922
const videoId = url.split('vimeo.com/')[1]?.split('?')[0];
2023
return videoId ? `https://player.vimeo.com/video/${videoId}` : url;
2124
}
25+
// For any other platform, return the URL as-is (no embedding transformation)
2226
return url;
2327
};
2428

src/content.config.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ const videos = defineCollection({
1111
url: z.string().url(),
1212
thumbnail: z.string().optional(),
1313
platform: z.preprocess(
14-
(val) => (typeof val === 'string' ? val.trim().toLowerCase() : val),
15-
z.string()
14+
(val) => {
15+
if (typeof val === 'string') {
16+
return val.trim().toLowerCase();
17+
}
18+
return val;
19+
},
20+
z.string().min(1) // Accept any non-empty string
1621
),
1722
duration: z.string().optional(),
1823
publishedDate: z.coerce.date().optional(),

src/content/videos/videos.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"title": "NetDriver Quick 5 Minute Setup Tutorial",
66
"description": "NetDriver is an advanced open-source framework for automating network devices. Its main purpose is to use a high-level HTTP RESTful interface to make it easier to execute low-level commands on different networking equipment.",
77
"url": "https://youtu.be/b7ZDJcVmz7Y",
8-
"platform": "youtube ",
8+
"platform": "youtube",
99
"publishedDate": "2026-01-28"
1010
}
1111
]

src/pages/videos.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ const videoSchemas = videos.map((video) => {
3535
};
3636
3737
// Add platform-specific properties
38-
if (video.platform === 'youtube') {
38+
const normalizedPlatform = video.platform?.trim().toLowerCase() || '';
39+
if (normalizedPlatform === 'youtube') {
3940
videoSchema.regionsAllowed = 'US';
4041
}
4142

0 commit comments

Comments
 (0)