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

Posts fail when change to getPosts #55

Open
vitormarquesds opened this issue Jan 10, 2023 · 2 comments
Open

Posts fail when change to getPosts #55

vitormarquesds opened this issue Jan 10, 2023 · 2 comments

Comments

@vitormarquesds
Copy link

vitormarquesds commented Jan 10, 2023

I'm having an error in the post. I do not know if this is the version, but I didn't find a solution

blog1
vlog2

error1
error2

@olamission
Copy link

Hi I found a solution instead of this :

export default function Home({ posts }) {

do this

export default function Home({ posts } : any ) {

its to do with typescript. it always needs a definition type for every parameter

@hellotaoworld
Copy link

I think the issue is in getStaticProps() function. It should be setting "posts" as a const and then point props to posts. Please see below.

export async function getStaticProps() {
  const posts = (await getPosts()) || [];
  return {
    props: { posts }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants