types#Post TypeScript Examples

The following examples show how to use types#Post. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: [...slug].tsx    From next-mdx with MIT License 6 votes vote down vote up
export async function getStaticProps(context) {
  const author = await getNode<Author>("author", context)

  if (!author) {
    return {
      notFound: true,
    }
  }

  const posts = await getAllNodes<Post>("post")

  return {
    props: {
      author,
      posts: posts.filter((post) =>
        post.relationships.author.some(({ slug }) => slug === author.slug)
      ),
    },
  }
}
Example #2
Source File: [...slug].tsx    From next-mdx with MIT License 6 votes vote down vote up
export async function getStaticProps(context) {
  const post = await getMdxNode<Post>("post", context)

  if (!post) {
    return {
      notFound: true,
    }
  }

  return {
    props: {
      post,
    },
  }
}
Example #3
Source File: [...slug].tsx    From next-mdx with MIT License 6 votes vote down vote up
export async function getStaticProps(context) {
  const category = await getNode<Category>("category", context)

  if (!category) {
    return {
      notFound: true,
    }
  }

  const posts = await getAllNodes<Post>("post")

  return {
    props: {
      category,
      posts: posts.filter((post) =>
        post.relationships.category.some(({ slug }) => slug === category.slug)
      ),
    },
  }
}
Example #4
Source File: blog.tsx    From next-mdx with MIT License 6 votes vote down vote up
export async function getStaticProps() {
  const posts = await getAllNodes<Post>("post")

  return {
    props: {
      posts,
    },
  }
}
Example #5
Source File: index.tsx    From next-mdx with MIT License 6 votes vote down vote up
export async function getStaticProps() {
  const posts = await getAllNodes<Post>("post")

  return {
    props: {
      posts: posts.filter((post) => post.frontMatter.featured),
    },
  }
}