Skip to content

Commit

Permalink
fix: rollback main page
Browse files Browse the repository at this point in the history
  • Loading branch information
C17AN committed Apr 3, 2022
1 parent cc6f2cd commit d44c261
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import Home from "components/Home";
import Head from "next/head";
import React, { useState } from "react";
import fs from "fs";
import path from "path";
import React, { createContext, useState } from "react";
import matter from "gray-matter";
import Post from "type/Post";
import Portfolio from "components/Home/Portfolio";

interface Props {}
type BasePageProps = {
posts: Post[];
};

export const RecentPostContext = createContext<{ recentPostList: Post[] } | null>(null);

const BasePage = (props: Props) => {
const BasePage = ({ posts }: BasePageProps) => {
const description = `코드와 음악, 그리고 맛있는 음식을 사랑하는 개발자입니다.`;
const ogSiteName = "즐겁게, 코드";
const recentPosts = posts.slice(5);
const [recentPostList, setRecentPostList] = useState<Post[]>(recentPosts);

console.log(posts);

return (
<>
Expand All @@ -16,9 +29,31 @@ const BasePage = (props: Props) => {
<meta property="og:site_name" content={ogSiteName} />
<meta property="og:description" content={description} />
</Head>
<Home />
{/* <RecentPostContext.Provider value={{ recentPostList }}>
<Home recentPosts={recentPosts} />
</RecentPostContext.Provider> */}
<Portfolio />
</>
);
};

export async function getStaticProps() {
const postsDirectory = path.join(process.cwd(), "data/posts");
const filenames = fs.readdirSync(postsDirectory);

const posts = filenames.map((filename) => {
const markdownWithMeta = fs.readFileSync(
path.join(process.cwd(), "data/posts", filename),
"utf-8"
);
const { data: frontMatter } = matter(markdownWithMeta);
return {
frontMatter,
filename: filename.split(".")[0],
};
});

return { props: { posts } };
}

export default BasePage;

1 comment on commit d44c261

@vercel
Copy link

@vercel vercel bot commented on d44c261 Apr 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.