Skip to content

404やエラーページ、NotFoundの実装 #6

Open
@atsuki-sakai

Description

@atsuki-sakai

課題
現状 getBlog や getNews で該当記事がなかった場合に「Blog not found」などが返るだけになっているが、それが最終的にどうレンダリングされるかは不確定。
Next.js 14系の場合はnot-found.tsx を用意すればきちんとした404ページを出せるし、redirect などの挙動も制御しやすい。
国際化対応の場合は多言語の404ページを用意し、ユーザーに優しいメッセージを出すほうが望ましい。

改善案
各言語フォルダ内に not-found.tsx を作成し、ユーザーにとって親切な404ページを表示する。
getBlog() でnullが返ってきた際に notFound()(Next.jsの関数)を呼び出すようにすれば、自動的に404ページへ誘導が可能になる。

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @atsuki-sakai

        Issue actions

          404やエラーページ、NotFoundの実装 · Issue #6 · atsuki-sakai/kurofune-hp