chrismwilliams / astro-theme-cactus

A simple Astro theme. Use it to create your blog or website.
https://astro-cactus.chriswilliams.dev/
MIT License
866 stars 132 forks source link

Cannot read properties of undefined (reading 'render') #260

Closed tanveermunavar closed 3 months ago

tanveermunavar commented 3 months ago

Hi ,

Thanks for such a beautiful template, I'm loving it !

Im trying to enable web analytics for Vercel deployment of this template. https://vercel.com/docs/analytics/quickstart#add-the-analytics-component-to-your-app

I have appended below code in the configuration here

output: 'server', adapter: vercel({ webAnalytics: { enabled: true, }, }),

Unfortunately I'm facing below issue.

02:17:07 [WARN] [router] getStaticPaths() ignored in dynamic page /src/pages/posts/[slug].astro. Addexport const prerender = true;to prerender the page as static HTML during the build process. 02:17:07 [WARN] [router] getStaticPaths() ignored in dynamic page /src/pages/posts/[...page].astro. Addexport const prerender = true;to prerender the page as static HTML during the build process. 02:17:07 [ERROR] Cannot read properties of undefined (reading 'render') Stack trace: at /Users/mt/Documents/tmo/github/tmolabs.com/src/pages/posts/[slug].astro:18:33 [...] See full stack trace in the browser, or rerun with --verbose. 02:17:07 [ERROR] Cannot read properties of undefined (reading 'render') Stack trace: at /Users/mt/Documents/tmo/github/tmolabs.com/src/pages/posts/[slug].astro:18:33 [...] See full stack trace in the browser, or rerun with --verbose. 02:17:28 [ERROR] Cannot read properties of undefined (reading 'render') Stack trace: at /Users/mt/Documents/tmo/github/tmolabs.com/src/pages/posts/[slug].astro:18:33 [...] See full stack trace in the browser, or rerun with --verbose. 02:17:28 [ERROR] Cannot read properties of undefined (reading 'render') Stack trace: at /Users/mt/Documents/tmo/github/tmolabs.com/src/pages/posts/[slug].astro:18:33 [...] See full stack trace in the browser, or rerun with --verbose.

Any help would be appreciated.

Thanks, Tanveer Munavar

chrismwilliams commented 3 months ago

Hey @tanveermunavar,

Once you enable Astro's SSR mode, getStaticPaths() no longer works for generating routes (as per docs).

You have a couple of options though, depending on whether you require SSR.

Hope that helps

tanveermunavar commented 3 months ago

Thanks Chrismwilliams/Astro-Theme-Cactus, this solved my issues.

On Mon, May 20, 2024 at 1:48 PM Chris Williams @.***> wrote:

Hey @tanveermunavar https://github.com/tanveermunavar,

Once you enable Astro's SSR mode, getStaticPaths() no longer works for generating routes (as per docs) https://docs.astro.build/en/guides/routing/#modifying-the-slug-example-for-ssr .

You have a couple of options though, depending on whether you require SSR.

  • If you do, and you want to SSR these pages, you're going to have to re-write every getStaticPaths() instance, as shown in the docs linked previous.
  • Otherwise, as alluded to in the error, change the output to "hybrid" and add const prerender = true; to routes with getStaticPaths()
  • Or just set the output to "static", as shown in the adaptor docs https://docs.astro.build/en/guides/integrations-guide/vercel/#choosing-a-target

Hope that helps

— Reply to this email directly, view it on GitHub https://github.com/chrismwilliams/astro-theme-cactus/issues/260#issuecomment-2119922898, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB23Y5C4AYFHLUENCIWKXADZDGWWHAVCNFSM6AAAAABH5X4OQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJZHEZDEOBZHA . You are receiving this because you were mentioned.Message ID: @.***>

-- Thanks, Mohamed Tanveer www.linkedin.com/in/tanveermunavar