diff options
author | flu0r1ne <flu0r1ne@flu0r1ne.net> | 2021-07-21 02:56:12 -0500 |
---|---|---|
committer | flu0r1ne <flu0r1ne@flu0r1ne.net> | 2021-07-21 02:56:12 -0500 |
commit | 51967b62cd274b10326a604d4db670e9e89f8fd5 (patch) | |
tree | 5899d3b976b0c419cfdacf99fe1f42ba5e4ce277 /pages/logs | |
parent | 9e54416ae5e095ef5d47eb0c7a642894dddf46aa (diff) | |
download | homepage-51967b62cd274b10326a604d4db670e9e89f8fd5.tar.xz homepage-51967b62cd274b10326a604d4db670e9e89f8fd5.zip |
Automatic generation of list on log page
Diffstat (limited to 'pages/logs')
-rw-r--r-- | pages/logs/index.tsx | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/pages/logs/index.tsx b/pages/logs/index.tsx index 7f11e86..ed3c58b 100644 --- a/pages/logs/index.tsx +++ b/pages/logs/index.tsx @@ -1,16 +1,43 @@ import DefaultPage from '../../templates/Default'; import Markdown from '../../components/Markdown'; + +import { GetStaticProps, GetStaticPropsContext } from 'next'; +import React, { FC } from 'react'; +import { getPosts, getMetadata, Post, PostMetadata } from '../../utils/Posts'; //@ts-ignore import md from './logs.md'; -export default function Logs() { + +interface Props { + posts: Post[] +}; + +const Logs : FC<Props> = ({ posts }) => { + console.log(posts); return( <DefaultPage path={"/logs"} > - <Markdown - md={md} - /> + <ul> + { + posts.map(({ directory, meta }) => ( + <li><a href={'/logs/' + directory}>{meta.name}</a></li> + )) + } + </ul> </DefaultPage> ); -}
\ No newline at end of file +}; + +export default Logs; + + +export const getStaticProps: GetStaticProps = async ( + context: GetStaticPropsContext +) => { + const posts = await getPosts(); + + return { + props: { posts: posts }, + } +} |