Skip to content

Commit

Permalink
feat: replace about and experience sections with v2
Browse files Browse the repository at this point in the history
  • Loading branch information
yutakusuno committed Jan 14, 2024
1 parent ce5edce commit bc74123
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 10 deletions.
11 changes: 4 additions & 7 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { NextPage, Metadata } from "next";

import About from "../components/about";
import AboutV2 from "../components/about-v2";
import ExperienceV2 from "../components/experience-v2";
import Projects from "../components/projects";
import Experience from "../components/experience";

export const metadata: Metadata = {
title: "Yuta Kusuno Portfolio",
Expand All @@ -12,14 +12,11 @@ const Home: NextPage = () => {
return (
<>
<section id="about">
<About />
<AboutV2 />
</section>
<section id="experience">
<Experience />
<ExperienceV2 />
</section>
{/* <section id="skills">
<Skills />
</section> */}
<section id="projects">
<Projects />
</section>
Expand Down
26 changes: 26 additions & 0 deletions components/about-v2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Container } from "@chakra-ui/react";

import { NotionProfilePage } from "./notion-profile-page";
import { notion } from "../lib/notion";
import { notionAboutPageId } from "../lib/config";

const AboutV2 = async () => {
if (!notionAboutPageId) return null;

const rootNotionPageId = notionAboutPageId;
const recordMap = await notion.getPage(rootNotionPageId);

return (
<Container
minHeight="100vh"
justifyContent="center"
alignItems="center"
display="flex"
pt={50}
>
<NotionProfilePage recordMap={recordMap} rootPageId={rootNotionPageId} />
</Container>
);
};

export default AboutV2;
26 changes: 26 additions & 0 deletions components/experience-v2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Container } from "@chakra-ui/react";

import { NotionProfilePage } from "./notion-profile-page";
import { notion } from "../lib/notion";
import { notionExperiencePageId } from "../lib/config";

const ExperienceV2 = async () => {
if (!notionExperiencePageId) return null;

const rootNotionPageId = notionExperiencePageId;
const recordMap = await notion.getPage(rootNotionPageId);

return (
<Container
minHeight="100vh"
justifyContent="center"
alignItems="center"
display="flex"
pt={50}
>
<NotionProfilePage recordMap={recordMap} rootPageId={rootNotionPageId} />
</Container>
);
};

export default ExperienceV2;
26 changes: 26 additions & 0 deletions components/notion-profile-page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use client";

import { useColorMode } from "@chakra-ui/react";
import { NotionRenderer } from "react-notion-x";
import { ExtendedRecordMap } from "notion-types";
import "react-notion-x/src/styles.css";

export const NotionProfilePage = ({
recordMap,
rootPageId,
}: {
recordMap: ExtendedRecordMap;
rootPageId: string;
}) => {
const { colorMode } = useColorMode();

if (!recordMap) return null;

return (
<NotionRenderer
recordMap={recordMap}
darkMode={colorMode === "dark"}
rootPageId={rootPageId}
/>
);
};
2 changes: 1 addition & 1 deletion components/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Projects: NextPage = () => {

return (
<Container minHeight="80vh" pt={50}>
<Heading fontSize={"3xl"} pb={10}>
<Heading fontSize={"2xl"} pb={10}>
Projects
</Heading>

Expand Down
7 changes: 7 additions & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const notionAboutPageId = process.env.NOTION_ABOUT_PAGE_ID;

export const notionExperiencePageId = process.env.NOTION_EXPERIENCE_PAGE_ID;

export const notionBlogDatabaseId = process.env.NOTION_BLOG_DATABASE_ID;

export const notionAuthToken = process.env.NOTION_AUTH_TOKEN;
3 changes: 2 additions & 1 deletion lib/notion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { NotionAPI } from "notion-client";
import { notionAuthToken } from "./config";

export const notion = new NotionAPI({
authToken: process.env.NOTION_AUTH_TOKEN,
authToken: notionAuthToken,
});

export function getRecordMap(id: string) {
Expand Down
3 changes: 2 additions & 1 deletion lib/posts.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { getRecordMap } from "./notion";
import { Post } from "../types/post";
import { notionBlogDatabaseId } from "./config";

export async function getAllPostsFromNotion() {
const allPosts: Post[] = [];
const recordMap = await getRecordMap(process.env.NOTION_BLOG_DATABASE_ID!);
const recordMap = await getRecordMap(notionBlogDatabaseId!);
const { block, collection } = recordMap;
const schema = Object.values(collection)[0].value.schema;
const propertyMap: Record<string, string> = {};
Expand Down

1 comment on commit bc74123

@vercel
Copy link

@vercel vercel bot commented on bc74123 Jan 14, 2024

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.