{
- show.videos.results.length && (
+ show.videos?.results?.length && (
<>
diff --git a/src/pages/games/[slug].astro b/src/pages/games/[slug].astro
index 85f46f3..213d7f2 100644
--- a/src/pages/games/[slug].astro
+++ b/src/pages/games/[slug].astro
@@ -1,6 +1,25 @@
---
import Layout from '@layouts/Layout.astro';
import GameDetailsFragment from '@pages/fragments/GameDetails/[slug].astro';
+import gameData from '@data/gameDetails.json';
+
+// For static site generation, pre-define all game slugs
+export async function getStaticPaths() {
+ try {
+ // Generate paths for all games
+ if (gameData && gameData.allGames && Array.isArray(gameData.allGames)) {
+ return gameData.allGames.map(game => ({
+ params: { slug: game.slug }
+ }));
+ } else {
+ console.error('Error in getStaticPaths for games: gameData.allGames is not an array');
+ return [];
+ }
+ } catch (error) {
+ console.error('Error in getStaticPaths for games:', error);
+ return []; // Fallback to empty paths if error
+ }
+}
---
diff --git a/src/pages/movies/[id].astro b/src/pages/movies/[id].astro
index ba849ba..419ed71 100644
--- a/src/pages/movies/[id].astro
+++ b/src/pages/movies/[id].astro
@@ -1,8 +1,33 @@
---
import Layout from '@layouts/Layout.astro';
import MovieDetails from '@pages/fragments/MovieDetails/[id].astro';
+import type { GetStaticPaths } from 'astro';
+import movieData from '@data/movieDetails.json';
+
+// This is required for static site generation
+export const getStaticPaths = (() => {
+ const allMovies = [];
+
+ // Collect all movies from all genres
+ Object.keys(movieData).forEach(genre => {
+ if (Array.isArray(movieData[genre])) {
+ allMovies.push(...movieData[genre]);
+ }
+ });
+
+ // Remove duplicates by movie ID
+ const uniqueMovies = [...new Map(allMovies.map(movie => [movie.id, movie])).values()];
+
+ return uniqueMovies.map((movie) => ({
+ params: { id: String(movie.id) },
+ props: { movieData: movie } // Pass the movie data as props
+ }));
+}) satisfies GetStaticPaths;
+
+const { id } = Astro.params;
+const { movieData: movieDetails } = Astro.props; // Get movie data from props
---
-
+
diff --git a/src/pages/people/[id].astro b/src/pages/people/[id].astro
index 66a5adf..ea2009b 100644
--- a/src/pages/people/[id].astro
+++ b/src/pages/people/[id].astro
@@ -1,6 +1,53 @@
---
import Layout from '@layouts/Layout.astro';
import PersonDetails from '@pages/fragments/PersonDetails/[id].astro';
+import movieData from '@data/movieDetails.json';
+
+// For static site generation, we need to pre-define all the people IDs
+// We'll extract person IDs from the movieDetails.json credits
+export async function getStaticPaths() {
+ // This set will store unique person IDs
+ const personIds = new Set();
+
+ try {
+ // Movie data is organized by genre categories
+ if (movieData) {
+ // Iterate through each genre category
+ Object.keys(movieData).forEach(genre => {
+ if (Array.isArray(movieData[genre])) {
+ // Iterate through each movie in this genre
+ movieData[genre].forEach(movie => {
+ // Add person IDs from cast if available
+ if (movie.credits?.cast) {
+ movie.credits.cast.forEach(castMember => {
+ if (castMember.id) {
+ personIds.add(String(castMember.id));
+ }
+ });
+ }
+
+ // Add person IDs from crew if available
+ if (movie.credits?.crew) {
+ movie.credits.crew.forEach(crewMember => {
+ if (crewMember.id) {
+ personIds.add(String(crewMember.id));
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+
+ // Convert the Set to an array of path objects
+ return Array.from(personIds).map(id => ({
+ params: { id },
+ }));
+ } catch (error) {
+ console.error("Error in getStaticPaths for people:", error);
+ return []; // Fallback to empty paths if error
+ }
+}
---
diff --git a/src/pages/podcasts/[id].astro b/src/pages/podcasts/[id].astro
index 94e9b23..91b7a3f 100644
--- a/src/pages/podcasts/[id].astro
+++ b/src/pages/podcasts/[id].astro
@@ -1,8 +1,29 @@
---
import Layout from '@layouts/Layout.astro';
import PodcastDetailsFragment from '@pages/fragments/PodcastDetails/[id].astro';
+import type { GetStaticPaths } from 'astro';
+import podcastData from '@data/podcastDetails.json';
+
+// This is required for static site generation
+export const getStaticPaths = (() => {
+ try {
+ if (podcastData && Array.isArray(podcastData.allPodcasts)) {
+ return podcastData.allPodcasts.map(podcast => ({
+ params: { id: podcast.id },
+ props: { podcastData: podcast } // Pass podcast data as props
+ }));
+ }
+ return [];
+ } catch (error) {
+ console.error("Error in getStaticPaths for podcasts:", error);
+ return []; // Fallback to empty paths if error or no data
+ }
+}) satisfies GetStaticPaths;
+
+const { id } = Astro.params;
+const { podcastData: podcast } = Astro.props; // Get podcast data from props
---
-
+
diff --git a/src/pages/tv/[id].astro b/src/pages/tv/[id].astro
index 7680bce..0633199 100644
--- a/src/pages/tv/[id].astro
+++ b/src/pages/tv/[id].astro
@@ -1,8 +1,32 @@
---
import Layout from '@layouts/Layout.astro';
import TvDetails from '@pages/fragments/TvDetails/[id].astro';
+import type { GetStaticPaths } from 'astro';
+import tvData from '@data/tvShowDetails.json';
+
+// This is required for static site generation
+export const getStaticPaths = (() => {
+ const allShows = [];
+
+ // Combine regular and spanish shows
+ if (Array.isArray(tvData.regular)) {
+ allShows.push(...tvData.regular);
+ }
+
+ if (Array.isArray(tvData.spanish)) {
+ allShows.push(...tvData.spanish);
+ }
+
+ return allShows.map((show) => ({
+ params: { id: String(show.id) },
+ props: { showData: show } // Pass the show data as props
+ }));
+}) satisfies GetStaticPaths;
+
+const { id } = Astro.params;
+const { showData } = Astro.props; // Get show data from props
---
-
+