import Link from '@/components/Link'; import { PageSEO } from '@/components/SEO'; import Tag from '@/components/Tag'; import siteMetadata from '@/data/siteMetadata'; import { getAllFilesFrontMatter } from '@/lib/mdx'; import formatDate from '@/lib/utils/formatDate'; import { GetStaticProps, InferGetStaticPropsType } from 'next'; import { PostFrontMatter } from 'types/PostFrontMatter'; import NewsletterForm from '@/components/NewsletterForm'; const MAX_DISPLAY = 5; export const getStaticProps: GetStaticProps<{ posts: PostFrontMatter[]; }> = async () => { const posts = await getAllFilesFrontMatter('blog'); return { props: { posts } }; }; export default function Home({ posts, }: InferGetStaticPropsType) { return ( <>

最近发布的文章

{siteMetadata.description}

    {!posts.length && '没有找到文章。 😭'} {posts.slice(0, MAX_DISPLAY).map((frontMatter) => { const { slug, date, title, summary, tags } = frontMatter; return (
  • Published on

    {title}

    {tags.map((tag) => ( ))}
    {summary}
    Read more →
  • ); })}
{posts.length > MAX_DISPLAY && (
All Posts →
)} {siteMetadata.newsletter.provider !== '' && (
)} ); }