workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

Type error when using the astro blog template with c3

Open jldec opened this issue 1 year ago • 0 comments

Which Cloudflare product(s) does this pertain to?

C3 (npm create cloudflare)

What version(s) of the tool(s) are you using?

C3 v2.29.2

What version of Node are you using?

v20.11.1

What operating system and version are you using?

macOS Sequoia v15.0.1

Describe the Bug

Observed behavior

Trying out the default Astro blog template with npm create cloudlare results in this error the first time you browse to any blog post.

TypeError
An error occurred.
post.render is not a function

The root cause of this is that the adapter sets the output mode to server (SSR), but the blog template assumes static rendering. A small change to the blog page template would be one way to avoid this.

Expected behavior

The default Astro blog template should "just work" with Cloudflare Pages.

Ideally the Astro Cloudflare adapter could be optional in the c3 Astro-specific logic, since SSR is not necessary for a pre-rendered static blog site to work with Cloudflare Pages.

The question of when to use SSR could also be clarified in the docs.

NOTE: This is not strictly a Cloudflare-only issue. See this Astro discord thread for a similar issue with the node SSR adapter.

Steps to reproduce

  • npm create cloudflare
  • choose the astro framework starter, then choose the blog template
  • npm run dev and browse to any blog post like http://localhost:4321/blog/markdown-style-guide/

cc: @kristianfreeman

Please provide a link to a minimal reproduction

https://github.com/jldec/pages-astro-oct-8

Please provide any relevant error logs

No response

jldec avatar Oct 08 '24 22:10 jldec