|
| 1 | +import { allDocs, Doc } from 'contentlayer/generated'; |
| 2 | +import { GetStaticProps } from 'next'; |
1 | 3 | import Head from 'next/head'; |
2 | | -import Image from 'next/image'; |
| 4 | +import Link from 'next/link'; |
3 | 5 |
|
4 | | -import styles from '~/styles/Home.module.css'; |
| 6 | +interface Props { |
| 7 | + docs: Doc[]; |
| 8 | +} |
5 | 9 |
|
6 | | -const Home = () => { |
| 10 | +export default function Home({ docs }: Props) { |
7 | 11 | return ( |
8 | | - <div className={styles.container}> |
| 12 | + <div> |
9 | 13 | <Head> |
10 | | - <title>Create Next App</title> |
| 14 | + <title>React Components</title> |
11 | 15 | <meta name='description' content='Generated by create next app' /> |
12 | 16 | <link rel='icon' href='/favicon.ico' /> |
13 | 17 | </Head> |
14 | 18 |
|
15 | | - <main className={styles.main}> |
16 | | - <h1 className={styles.title}> |
17 | | - Welcome to <a href='https://nextjs.org'>Next.js!</a> |
18 | | - </h1> |
19 | | - |
20 | | - <p className={styles.description}> |
21 | | - Get started by editing{' '} |
22 | | - <code className={styles.code}>pages/index.tsx</code> |
23 | | - </p> |
24 | | - |
25 | | - <div className={styles.grid}> |
26 | | - <a href='https://nextjs.org/docs' className={styles.card}> |
27 | | - <h2>Documentation →</h2> |
28 | | - <p>Find in-depth information about Next.js features and API.</p> |
29 | | - </a> |
30 | | - |
31 | | - <a href='https://nextjs.org/learn' className={styles.card}> |
32 | | - <h2>Learn →</h2> |
33 | | - <p>Learn about Next.js in an interactive course with quizzes!</p> |
34 | | - </a> |
35 | | - |
36 | | - <a |
37 | | - href='https://github.com/vercel/next.js/tree/canary/examples' |
38 | | - className={styles.card}> |
39 | | - <h2>Examples →</h2> |
40 | | - <p>Discover and deploy boilerplate example Next.js projects.</p> |
41 | | - </a> |
42 | | - |
43 | | - <a |
44 | | - href='https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app' |
45 | | - className={styles.card}> |
46 | | - <h2>Deploy →</h2> |
47 | | - <p> |
48 | | - Instantly deploy your Next.js site to a public URL with Vercel. |
49 | | - </p> |
50 | | - </a> |
51 | | - </div> |
| 19 | + <main className='flex-grow px-10 py-5'> |
| 20 | + <h1 className='text-4xl text-primary mb-10'>React Components</h1> |
| 21 | + {docs.map(doc => { |
| 22 | + return ( |
| 23 | + <Link key={doc._id} href={`/${doc.title}`}> |
| 24 | + <div className='mb-6 last:mb-0'> |
| 25 | + <h2 className='text-2xl mb-2'>{doc.title}</h2> |
| 26 | + <p>{doc.intro}</p> |
| 27 | + </div> |
| 28 | + </Link> |
| 29 | + ); |
| 30 | + })} |
52 | 31 | </main> |
53 | | - |
54 | | - <footer className={styles.footer}> |
55 | | - <a |
56 | | - href='https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app' |
57 | | - target='_blank' |
58 | | - rel='noopener noreferrer'> |
59 | | - Powered by{' '} |
60 | | - <span className={styles.logo}> |
61 | | - <Image src='/vercel.svg' alt='Vercel Logo' width={72} height={16} /> |
62 | | - </span> |
63 | | - </a> |
64 | | - </footer> |
65 | 32 | </div> |
66 | 33 | ); |
67 | | -}; |
| 34 | +} |
68 | 35 |
|
69 | | -export default Home; |
| 36 | +export const getStaticProps: GetStaticProps<{ docs: Doc[] }> = () => { |
| 37 | + const docs = allDocs; |
| 38 | + |
| 39 | + return { props: { docs } }; |
| 40 | +}; |
0 commit comments