[basic-example][m] - remove everything related to multiple pages

This commit is contained in:
Luccas Mateus de Medeiros Gomes
2023-04-26 07:48:07 -03:00
parent 74a4f9a8ed
commit 8743f0d572
5 changed files with 49 additions and 129 deletions

View File

@@ -1,71 +1,48 @@
import Head from 'next/head'
import Image from 'next/image'
import styles from '../styles/Home.module.css'
import { GetStaticProps } from 'next';
import { promises as fs } from 'fs';
import path from 'path';
import parse from '../lib/markdown';
import DRD from '../components/DRD';
export default function Home() {
export const getStaticProps: GetStaticProps = async (context) => {
const contentDir = path.join(process.cwd(), '/content');
const datasets = await fs.readdir(contentDir);
const datasetReadme = path.join(
process.cwd(),
'/content/' + datasets[0] + '/README.md'
);
const readme = await fs.readFile(datasetReadme, 'utf8');
let { mdxSource, frontMatter, excerpt } = await parse(readme, '.mdx');
return {
props: {
mdxSource,
frontMatter,
excerpt,
},
};
};
export default function DatasetPage({ mdxSource, frontMatter, excerpt }) {
return (
<div className={styles.container}>
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={styles.main}>
<h1 className={styles.title}>
Welcome to <a href="https://nextjs.org">Next.js!</a>
</h1>
<p className={styles.description}>
Get started by editing{' '}
<code className={styles.code}>pages/index.tsx</code>
</p>
<div className={styles.grid}>
<a href="https://nextjs.org/docs" className={styles.card}>
<h2>Documentation &rarr;</h2>
<p>Find in-depth information about Next.js features and API.</p>
</a>
<a href="https://nextjs.org/learn" className={styles.card}>
<h2>Learn &rarr;</h2>
<p>Learn about Next.js in an interactive course with quizzes!</p>
</a>
<a
href="https://github.com/vercel/next.js/tree/canary/examples"
className={styles.card}
>
<h2>Examples &rarr;</h2>
<p>Discover and deploy boilerplate example Next.js projects.</p>
</a>
<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
className={styles.card}
>
<h2>Deploy &rarr;</h2>
<p>
Instantly deploy your Next.js site to a public URL with Vercel.
</p>
</a>
<div className="prose mx-auto">
<header>
<div className="mb-6">
<>
<h1>{frontMatter.title}</h1>
{frontMatter.author && (
<div className="-mt-6">
<p className="opacity-60 pl-1">{frontMatter.author}</p>
</div>
)}
{frontMatter.description && (
<p className="description">{frontMatter.description}</p>
)}
</>
</div>
</header>
<main>
<DRD source={mdxSource} />
</main>
<footer className={styles.footer}>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Powered by{' '}
<span className={styles.logo}>
<Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
</span>
</a>
</footer>
</div>
)
);
}