Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output export ssg generation for dynamic even with generateStaticParams id value is comming as %5Bslug%5D so page is not generated in build #65560

Open
veract-dev opened this issue May 9, 2024 · 1 comment
Labels
bug Issue was opened via the bug report template.

Comments

@veract-dev
Copy link

Link to the code that reproduces this issue

https://github.com/veract-dev/prahars.git

To Reproduce

nextjs.config


/** @type {import('next').NextConfig} */
const nextConfig = {

    output: 'export',
    trailingSlash: true,

    images: {
        unoptimized: true,
    },


}

module.exports = nextConfig

blog/[slug]/page.tsx


export async function generateStaticParams() {
    const blogs = (await getAllBlogs()).data;
    if (blogs && blogs.length > 0) {
        let final = blogs.map((blog: BlogI) => ({
            slug: blog.id
        }))

        return final;
    } else {
        return [];

    }

export default async function Page({ params }: any) {
    let { slug } = params
    console.log("id before", slug)
    let data = (await getBlog(slug)).data;
    let blog = data as BlogI ?? null;

    return (
        <div>
            <div className="desktopBlogInnerPage">
                <div className="innerpage_title">{blog?.title}</div>

                <div className="image-container img"><Image src={blog.thumbnail} alt="Description of the image" width={1000} height={667} /></div>
                <div className="innerpage_content_padding">
                    {blog.content}
                </div>
            </div>

            <div className="mobileBlogInnerPage">
                <div className="innerpage_title">{blog.title}</div>
                <div className="image-container_mobile">
                    <div className="image-container img_mobile"><Image src={blog.thumbnail} alt="Description of the image" width={1000} height={667} /></div>
                </div>
                {/* <div style={{display: "flex", justifyContent:"center", backgroundSize:'contain', paddingTop:"40px"}}><div className="background_img"></div></div> */}
                <div className="innerpage_content_padding">
                    {blog.content}
                </div>
            </div>
        </div>
    )



}

Current vs. Expected behavior

Current behavior in npm build files are not generated for id with value Expected behavior to build files and generate

Provide environment information

Operating System:
  Platform: windows
  Arch: x64
  Version: 12
Binaries:
  Node: 20.9.0
  npm: 9.4.0
  pnpm: N/A
Relevant packages:
  next: 14.2.3
  eslint-config-next: N/A
  react: ^18
  react-dom: ^18

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

updated code is in master branch

@veract-dev veract-dev added the bug Issue was opened via the bug report template. label May 9, 2024
@lemoolu
Copy link

lemoolu commented May 22, 2024

I have the same problem , I think it's because next will encodeURIComponent the data returned by generateStaticParams, and then passing to the the component's props.params,which results props.params can not match the data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants