2022-10-07 23:43:39 +02:00
|
|
|
import type { GetServerSideProps, NextPage } from "next";
|
|
|
|
import Layout from "../../../components/Blog/Layout";
|
2022-10-15 22:17:51 +02:00
|
|
|
import ContentPage from "../../../components/Blog/ContentPage";
|
2022-10-08 13:28:16 +02:00
|
|
|
import { generateContent, getContentList } from "../../../lib/content/generateBackend";
|
2022-10-15 22:17:51 +02:00
|
|
|
import type { ContentList, DiaryRender, Diary } from "../../../lib/content/types";
|
2022-10-07 23:43:39 +02:00
|
|
|
|
|
|
|
import styles from "../../../styles/Blog/Content.module.scss";
|
|
|
|
|
2022-10-15 22:17:51 +02:00
|
|
|
const DiaryMain: NextPage<{ content: DiaryRender }> = ({ content }) => {
|
2022-10-07 23:43:39 +02:00
|
|
|
return <Layout title={`${content.title} - c0ntroller.de`}>
|
2022-10-15 22:17:51 +02:00
|
|
|
<ContentPage content={content} />
|
2022-10-07 23:43:39 +02:00
|
|
|
</Layout>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
|
|
|
const { did } = context.query;
|
2022-10-08 13:28:16 +02:00
|
|
|
const contentList = await getContentList();
|
|
|
|
|
|
|
|
const contentEntry: Diary | undefined = (contentList as ContentList).find((c) => c.name === did && c.type === "diary") as Diary | undefined;
|
2022-10-07 23:43:39 +02:00
|
|
|
|
|
|
|
if (!contentEntry) return { notFound: true };
|
|
|
|
|
|
|
|
const contentHtml = await generateContent(contentEntry);
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
content: {
|
2022-10-08 13:28:16 +02:00
|
|
|
...contentEntry,
|
2022-10-15 22:17:51 +02:00
|
|
|
html: contentHtml,
|
|
|
|
pageSelected: 0
|
2022-10-07 23:43:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default DiaryMain;
|