feat: youtube feed (#374)

- [x] add PSE youtube channel youtube feed in homepage
This commit is contained in:
Kalidou Diagne
2025-05-05 21:54:45 +03:00
committed by GitHub
parent 50a9a032b6
commit c7f8cbe0ac
11 changed files with 286 additions and 7 deletions

26
hooks/useYoutube.ts Normal file
View File

@@ -0,0 +1,26 @@
import { useQuery } from "@tanstack/react-query"
async function fetchYoutubeVideos() {
try {
const response = await fetch("/api/youtube", {
cache: "default",
})
if (!response.ok) {
throw new Error(`Failed to fetch videos: ${response.status}`)
}
const data = await response.json()
return data.videos || []
} catch (error) {
console.error("Error fetching videos:", error)
return []
}
}
export const useYoutube = () => {
return useQuery({
queryKey: ["pse-youtube-videos"],
queryFn: () => fetchYoutubeVideos(),
})
}