Changed channel to playlist

This commit is contained in:
cdricms
2025-02-13 12:27:13 +01:00
parent f96d25e31f
commit 3974e428aa
3 changed files with 21 additions and 6 deletions

View File

@@ -9,13 +9,16 @@ import YouTubeEmbed from "@/components/youtube-embed";
import { IYoutube } from "@/interfaces/youtube";
import getShortcode from "@/lib/getShortcode";
const PLAYLIST_ID = "PLh8PxbpRguvNlmarfGkCTAd-UVAG4QpE9";
export default async function Home() {
let videos: IYoutube | null = null;
if (process.env.YOUTUBE_API_KEY) {
const query = `https://www.googleapis.com/youtube/v3/search?key=${process.env.YOUTUBE_API_KEY}&channelId=UCzuFLl5I0WxSMqbeMaiq_FQ&part=snippet,id&order=date&maxResults=50`;
const query = `https://www.googleapis.com/youtube/v3/playlistItems?key=${process.env.YOUTUBE_API_KEY}&playlistId=${PLAYLIST_ID}&part=snippet,id&maxResults=50`;
const res = await fetch(query);
videos = await res.json();
}
console.log(videos);
const hero = await getShortcode("hero_image");
const systemEvolution = await getShortcode("evolution_systeme");
const fondations = await getShortcode("fondements");
@@ -165,9 +168,13 @@ export default async function Home() {
title="Vidéos YouTube"
>
{videos.items.map((video) => {
const id =
typeof video.id !== "string"
? video.id.videoId
: video.snippet.resourceId.videoId;
return (
<CarouselItem
key={video.id.videoId}
key={id}
className="pl-[20px] md:max-w-[452px]"
>
<YouTubeEmbed video={video} />