Skip to content

AstroをC3で簡単に Cloudflare へデプロイした

Posted on:2023年12月23日

手順

  1. Cloudflareアカウントを作る(メール認証まで済ませる)
  2. npm create cloudflare@latest
    1. astroを選ぶ
    2. blogを選んだ
  3. そのまま流れでdeployできる

注意点

そのままだとdynamic routing部分がエラーになる(SSGの設定が必要) post.render is not a function

ビルドすると、以下のwarningが出てる

[WARN] [router] getStaticPaths() ignored in dynamic page /src/pages/blog/[...slug].astro. Add `export const prerender = true;` to prerender the page as static HTML during the build process.

警告通り、src/pages/blog/[...slug].astroに以下を追加 ```astro:src/pages/blog/[...slug].astro

ssgすることが明示的になる