最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

next.js - How do I enable static generation when using [locale] and next-intl with nextjs 15 - Stack Overflow

programmeradmin2浏览0评论

I've been trying to get SSG to work properly with NextJs 15 and next-intl for localization as my site has 2 locales: en and es

I tried the following:

    import { routing } from '@/i18n/routing';
    import { setRequestLocale } from "next-intl/server";
    import { use } from "react";

    // This ensures all possible paths are generated at build time
    export function generateStaticParams({params}) {
        return routing.locales.map((locale) => ({ locale }));
    }
    
    export default  function CacheTest({params}) {
        const {locale} = use(params);
        // Enable static rendering
        setRequestLocale(locale);
        
        return (
            <section className="cache-test">
                <h1>This page should be static!</h1>
                <p>{params.locale}</p>
           
            </section>
        );
    }```

When I run the build, it appears as if the pages are statically generated:

├ ● /[locale]/cache-test                 180 B           111 kB
├   ├ /en/cache-test
├   └ /da/cache-test

But when I check the output, there are no html files generated.

Am I doing this wrong?
发布评论

评论列表(0)

  1. 暂无评论