import {GetStaticProps, NextPage} from 'next';
import {getReadmeText} from '../src/data';
import ReactMarkdown from 'react-markdown';
import {Wrapper} from '../components/Wrapper';

interface IndexPageProps {
	readmeType: 'markdown';
	readmeText: string;
}

const IndexPage: NextPage<IndexPageProps> = ({
	readmeType,
	readmeText,
}) => {
	return (
		<Wrapper>
			{readmeType === 'markdown' && (
				<ReactMarkdown>
					{readmeText}
				</ReactMarkdown>
			)}
		</Wrapper>
	);
};

export const getStaticProps: GetStaticProps<IndexPageProps> = async () => {
	const readmeText = await getReadmeText();
	return {
		props: {
			readmeType: 'markdown',
			readmeText,
		},
	};
};

export default IndexPage;
