Add project page

This commit is contained in:
2022-10-07 23:03:39 +02:00
parent 85acc1bdac
commit f30332bc5e
16 changed files with 1677 additions and 36 deletions

View File

@ -1,6 +1,6 @@
import type { AppProps } from "next/app";
import Head from "next/head";
import "../styles/globals.css";
import "../styles/globals.scss";
import { CommandsProvider } from "../lib/commands/ContextProvider";
import { ModalFunctionProvider } from "../components/Terminal/contexts/ModalFunctions";

View File

@ -0,0 +1,54 @@
import type { GetServerSideProps, NextPage } from "next";
import Head from "next/head";
import Navigation from "../../../components/Blog/Navigation";
import { generateContent } from "../../../lib/content/generateBackend";
import type { ContentList } from "../../../lib/content/types";
import contentList from "../../../public/content/list.json";
import styles from "../../../styles/Blog/Content.module.scss";
interface IContentRender {
more?: string;
repo?: string;
title: string;
html: string;
}
const Post: NextPage<{ content: IContentRender }> = ({ content }) => {
return <>
<Head>
<title>{content.title} - c0ntroller.de</title>
</Head>
<div id={"blogBody"}>
<header>
<Navigation />
</header>
<main dangerouslySetInnerHTML={{ __html: content.html}}>
</main>
</div>
</>;
};
export const getServerSideProps: GetServerSideProps = async (context) => {
const { pid } = context.query;
const contentEntry = (contentList as ContentList).find((c) => c.name === pid && c.type === "project");
if (!contentEntry) return { notFound: true };
const contentHtml = await generateContent(contentEntry);
return {
props: {
content: {
more: contentEntry.more || null,
repo: contentEntry.repo || null,
title: contentEntry.title,
html: contentHtml
}
}
};
};
export default Post;

View File

@ -3,18 +3,21 @@ import Head from "next/head";
import type { ContentList } from "../lib/content/types";
import Navigation from "../components/Blog/Navigation";
import ProjectCard from "../components/Blog/Card";
import contentList from "../public/content/list.json";
import styles from "../styles/Blog/Front.module.scss";
const Blog: NextPage<{ content: ContentList }> = ({content}) => {
const generateCards = (type: string) => {
return <div className={styles.contentList}>{content.filter(p => p.type === type).map(p => <ProjectCard key={p.name} title={p.title} description={p.desc.join(" ")} />)}</div>;
return <div className={styles.contentList}>{content.filter(p => p.type === type).map(p => <ProjectCard key={p.name} title={p.title} description={p.desc.join(" ")} type={p.type} name={p.name} />)}</div>;
};
return <>
<Head>
<title>c0ntroller.de</title>
</Head>
<div className={styles.container}>
<div id={"blogBody"}>
<header>
<Navigation />
</header>
@ -32,11 +35,7 @@ const Blog: NextPage<{ content: ContentList }> = ({content}) => {
};
export async function getServerSideProps() {
const url = process.env.BASE_URL || "https://c0ntroller.de";
const res = await fetch(`${url}/content/list.json`);
const content = await res.json();
return { props: { content } };
return { props: { content: contentList } };
}
export default Blog;