Skip to content

Commit a70472e

Browse files
committed
youtube and community badges
1 parent 6ce5b7a commit a70472e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/components/TutorialsGrid.astro

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ const difficulties = {
9090
throw new Error(`${tutorial.id} is missing difficulty property`);
9191
}
9292

93-
const video = tutorial.collection === "videos";
93+
const YOUTUBE_DOMAINS = ["www.youtube.com", "youtube.com", "youtu.be"];
94+
const youtube =
95+
tutorial.collection === "videos" &&
96+
YOUTUBE_DOMAINS.includes(new URL(tutorial.data.link).hostname);
9497

9598
const spotlight =
9699
tutorial.collection === "docs" && tutorial.data.spotlight;
@@ -102,16 +105,16 @@ const difficulties = {
102105
},
103106
];
104107

105-
if (video) {
108+
if (youtube) {
106109
badges.push({
107-
text: "Video",
110+
text: "YouTube",
108111
variant: "note",
109112
});
110113
}
111114

112115
if (spotlight) {
113116
badges.push({
114-
text: "Spotlight",
117+
text: "Community",
115118
variant: "tip",
116119
});
117120
}

0 commit comments

Comments
 (0)