Changed channel to playlist
This commit is contained in:
@@ -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} />
|
||||
|
||||
Reference in New Issue
Block a user