Skip to content

Refactor to fix bug - implement static site generation - #17

Open
JuanPabloDiaz wants to merge 4 commits into
mainfrom
ssr
Open

Refactor to fix bug - implement static site generation#17
JuanPabloDiaz wants to merge 4 commits into
mainfrom
ssr

Conversation

@JuanPabloDiaz

Copy link
Copy Markdown
Owner

fixes #16
This pull request transitions the project from server-side rendering (SSR) to static site generation (SSG) and includes changes to predefine static paths for various dynamic routes. It modifies the astro.config.mjs file to set the output to static and introduces getStaticPaths functions across multiple pages and fragments to enable SSG. Additionally, it refactors how data is fetched and passed to components, replacing runtime API calls with preloaded JSON data.

Configuration Update:

  • astro.config.mjs: Changed output from 'server' to 'static' to optimize for static site generation and reduce serverless function calls. Removed the Vercel adapter as it is no longer needed for SSG.

Static Paths Implementation for Pages:

Static Paths Implementation for Fragments:

These changes collectively enable static site generation, improve performance, and reduce reliance on runtime API calls by leveraging preloaded JSON data for dynamic routing.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 16, 2025

Copy link
Copy Markdown

Deploying juan-favorites with  Cloudflare Pages  Cloudflare Pages

Latest commit: ccc9501
Status:🚫  Build failed.

View logs

@JuanPabloDiaz
JuanPabloDiaz requested a review from Copilot June 16, 2025 22:34
@JuanPabloDiaz JuanPabloDiaz self-assigned this Jun 16, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors the project to use static site generation instead of server‐side rendering, reducing serverless function calls and optimizing performance. Key changes include updating the Astro configuration to output static files, implementing getStaticPaths functions for multiple dynamic pages and fragments, and refactoring data fetching to use preloaded JSON data.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/pages/tv/[id].astro Added getStaticPaths using combined TV show data and passed props to TvDetails.
src/pages/podcasts/[id].astro Implemented getStaticPaths and updated PodcastDetailsFragment usage.
src/pages/people/[id].astro Added getStaticPaths that extracts unique person IDs from movie credits.
src/pages/movies/[id].astro Added getStaticPaths to generate unique movie paths and passed movie data as props.
src/pages/games/[slug].astro Introduced getStaticPaths for game pages with improved error handling.
src/pages/fragments/TvDetails/[id].astro Updated getStaticPaths and adjusted data processing with optional chaining.
src/pages/fragments/PodcastList/index.astro Replaced Astro.glob with direct JSON import for podcasts data.
src/pages/fragments/PodcastDetails/[id].astro Refactored to use preloaded podcast data via static props.
src/pages/fragments/PersonDetails/[id].astro Added static paths generation for person details from movie credits.
src/pages/fragments/MovieDetails/[id].astro Updated static path generation and data formatting using the preloaded movie JSON.
src/pages/fragments/GameDetails/[slug].astro Refactored static generation with improved error handling and prop usage.
src/pages/fragments/BookDetails/[id].astro Implemented getStaticPaths for book details with preloaded JSON data.
src/pages/books/[id].astro Added getStaticPaths to predefine book paths for SSG and removed SSR comments.
src/pages/artists/[mbid].astro Added getStaticPaths for artist pages using preloaded artist data.
astro.config.mjs Updated configuration to output static files and removed Vercel adapter.
Comments suppressed due to low confidence (1)

src/pages/fragments/BookDetails/[id].astro:21

  • Consider destructuring 'bookData' from Astro.props (like in other pages) to leverage the preloaded JSON data and avoid runtime fetches.
const { id } = Astro.params; // Get the book's OpenLibrary Work ID from the URL

Comment on lines +11 to +12
if (tvShowDetailsJson && tvShowDetailsJson.regular) {
return tvShowDetailsJson.regular.map(show => ({

Copilot AI Jun 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the main TV page, consider combining 'tvShowDetailsJson.spanish' with 'tvShowDetailsJson.regular' in the static path generation.

Suggested change
if (tvShowDetailsJson && tvShowDetailsJson.regular) {
return tvShowDetailsJson.regular.map(show => ({
if (tvShowDetailsJson && (tvShowDetailsJson.regular || tvShowDetailsJson.spanish)) {
const combinedShows = [
...(tvShowDetailsJson.regular || []),
...(tvShowDetailsJson.spanish || [])
];
return combinedShows.map(show => ({

Copilot uses AI. Check for mistakes.
// }
// return []; // Fallback to empty paths if error or no data
// }
// For static site generation, getStaticPaths is required for dynamic routing

Copilot AI Jun 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider passing the full book data as props in getStaticPaths to maintain consistency with other dynamic routes and eliminate potential runtime fetching.

Copilot uses AI. Check for mistakes.
@netlify

netlify Bot commented Jun 17, 2025

Copy link
Copy Markdown

Deploy Preview for jpfav ready!

Name Link
🔨 Latest commit ece2fee
🔍 Latest deploy log https://app.netlify.com/projects/jpfav/deploys/6851c54be592cc00084a486b
😎 Deploy Preview https://deploy-preview-17--jpfav.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

⚠️ Production overload due to excessive traffic on /_render – blocked by Vercel

2 participants