5142c0e542
* initial commit
* delete comment
* env name fix
* Update README.md
* remove hapi-boom
* use next-image
* fix alt attr
* date fix for blog posts
* reset gitignore
* fix react best-practices
* prettier
* mdx to md
* fix prettier config. lint 👍
* Update examples/blog-with-comment/components/comment/list.js
Co-authored-by: Lee Robinson <me@leerob.io>
* refactor api methods
* fix: blog title
* fix: html lang
* next-mdx to gray-matter
Co-authored-by: Noah Fischer <78238464+noahfschr@users.noreply.github.com>
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Enes Akar <enesakar@gmail.com>
34 lines
959 B
JavaScript
34 lines
959 B
JavaScript
import Link from 'next/link'
|
|
import Container from '../../components/container'
|
|
import distanceToNow from '../../lib/dateRelative'
|
|
import { getAllPosts } from '../../lib/getPost'
|
|
|
|
export default function NotePage({ allPosts }) {
|
|
return (
|
|
<Container>
|
|
{allPosts.length ? (
|
|
allPosts.map((post) => (
|
|
<article key={post.slug} className="mb-10">
|
|
<Link as={`/posts/${post.slug}`} href="/posts/[slug]">
|
|
<a className="text-lg leading-6 font-bold">{post.title}</a>
|
|
</Link>
|
|
<p>{post.excerpt}</p>
|
|
<div className="text-gray-400">
|
|
<time>{distanceToNow(new Date(post.date))}</time>
|
|
</div>
|
|
</article>
|
|
))
|
|
) : (
|
|
<p>No blog posted yet :/</p>
|
|
)}
|
|
</Container>
|
|
)
|
|
}
|
|
|
|
export async function getStaticProps() {
|
|
const allPosts = getAllPosts(['slug', 'title', 'excerpt', 'date'])
|
|
|
|
return {
|
|
props: { allPosts },
|
|
}
|
|
}
|