From f75e45311ff48d14aa28ae6899a13b26b751c005 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Tue, 30 Mar 2021 14:54:22 +0200 Subject: pinned posts on homepage working --- pages/index.tsx | 133 +++++++++++++++++----------------------------------- pages/post/[id].tsx | 20 ++++---- 2 files changed, 54 insertions(+), 99 deletions(-) (limited to 'pages') diff --git a/pages/index.tsx b/pages/index.tsx index a08825a..be70ee6 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,110 +1,61 @@ +import Navbar, { NavbarItem } from '../components/navbar'; +import Chapters, { chapter } from '../components/chapters'; import Seperator from '../components/seperator'; -import Navbar from '../components/navbar'; -import Button from '../components/button'; -import Image from '../components/image'; -import Chapters from '../components/chapters'; -import Tags from '../components/tag'; -import ReactMarkdown from 'react-markdown'; +import { getStaticProps as getBlogPage, ArticleMeta, RenderedArticle } from './post/[id]'; -export default function Home() { +var posts = ["index", "index", "index"]; + +export default function Home(props: { + posts: Array<{ + props: { + content: string, + meta: ArticleMeta + } + }> +}) { return
-

Loek’s excruciatingly interesting blog

-

Loek heeft dit geschreven

- +

{props.posts[0].props.meta.title}

+ { + return { + children: post.props.meta.chapters, + name: post.props.meta.title, + } as chapter + }) ]}/>
- - - -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Gravida dictum fusce ut placerat orci nulla pellentesque. Laoreet id donec ultrices tincidunt arcu. Tortor aliquam nulla facilisi cras fermentum odio eu feugiat. A scelerisque purus semper eget duis at tellus. A iaculis at erat pellentesque adipiscing commodo elit at imperdiet. Arcu bibendum at varius vel pharetra vel turpis nunc eget. Euismod in pellentesque massa placerat duis. Lorem ipsum dolor sit amet consectetur adipiscing elit. Ultrices in iaculis nunc sed augue lacus. Vestibulum mattis ullamcorper velit sed. Adipiscing diam donec adipiscing -

- Here's a link -
} + +export function getStaticProps() { + var postsContent = []; + + posts.forEach(id => { + postsContent.push(getBlogPage({ params: { id } })); + }) + + var staticProps = { props: { posts: postsContent } }; + console.log(staticProps) + + return staticProps +} diff --git a/pages/post/[id].tsx b/pages/post/[id].tsx index 3144057..23ce14e 100644 --- a/pages/post/[id].tsx +++ b/pages/post/[id].tsx @@ -10,7 +10,7 @@ import Image from '../../components/image'; import Chapters, { chapter } from '../../components/chapters'; import Tags from '../../components/tag'; -interface ArticleMeta { +export interface ArticleMeta { title?: string; subtitle?: string; author?: string; @@ -19,6 +19,16 @@ interface ArticleMeta { chapters?: Array; } +export function RenderedArticle(props: { content: string }) { + return ; +} + var headingLevel = (input: string) => input?.match(/^[#]+/)[0]?.length || 0; var sectionID = (input: string) => input @@ -52,13 +62,7 @@ export default function Post(props: {
- +
-- cgit v1.2.3