-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from shunkakinoki/feat/ini-blog-page-v3
feat: ini blog page
- Loading branch information
Showing
15 changed files
with
376 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
NEXTAUTH_URL=https://shunkakinoki.com | ||
NOTION_BLOG_ID=e4ef762ca07f465e8f5cce906732140b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
.notion { | ||
@apply leading-relaxed; | ||
} | ||
|
||
.notion a { | ||
@apply underline; | ||
} | ||
|
||
.notion p { | ||
@apply my-3; | ||
} | ||
|
||
.notion h1 { | ||
@apply my-8 text-6xl font-semibold tracking-tight; | ||
} | ||
|
||
.notion h2 { | ||
@apply my-6 text-4xl font-semibold leading-tight; | ||
} | ||
|
||
.notion h3 { | ||
@apply my-5 text-2xl font-semibold leading-snug; | ||
} | ||
|
||
.notion h4 { | ||
@apply my-4 text-2xl; | ||
} | ||
|
||
.notion h5 { | ||
@apply my-3 text-3xl font-light; | ||
} | ||
|
||
.notion h6 { | ||
@apply my-3 text-xl font-thin; | ||
} | ||
|
||
.notion ul { | ||
@apply mx-4 my-6 text-lg font-semibold list-disc sm:my-9; | ||
} | ||
|
||
.notion li { | ||
@apply my-1; | ||
} | ||
|
||
.notion ol { | ||
@apply mx-4 my-6 text-lg font-semibold list-decimal list-inside sm:my-9; | ||
} | ||
|
||
.notion table { | ||
@apply table-caption w-full max-w-screen-lg overflow-hidden table-auto; | ||
} | ||
|
||
.notion th { | ||
@apply relative font-serif text-2xl font-semibold leading-relaxed text-left border-collapse; | ||
} | ||
|
||
.notion td { | ||
@apply px-4 py-2 font-serif leading-relaxed; | ||
} | ||
|
||
.notion blockquote { | ||
@apply p-3 mx-16 my-auto font-serif text-xl italic; | ||
} | ||
|
||
.notion blockquote > p { | ||
@apply max-w-screen-md mx-0 my-auto text-2xl font-bold; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
|
||
import type { PagesRetrieveResponse } from "@notionhq/client/build/src/api-endpoints"; | ||
import type { Block, RichText } from "@notionhq/client/build/src/api-types"; | ||
import clsx from "clsx"; | ||
import { Fragment } from "react"; | ||
import type { FC } from "react"; | ||
|
||
import s from "./Notion.module.css"; | ||
|
||
export type Props = { | ||
blocks: Block[]; | ||
content: PagesRetrieveResponse; | ||
}; | ||
|
||
export type TextProps = { | ||
text: RichText[]; | ||
}; | ||
|
||
export const Text: FC<TextProps> = ({ text }) => { | ||
return ( | ||
<> | ||
{text.map((value, id) => { | ||
const { | ||
annotations: { bold, code, italic, strikethrough, underline }, | ||
plain_text, | ||
href, | ||
} = value; | ||
return ( | ||
<span | ||
key={id} | ||
className={clsx( | ||
bold && "font-extrabold", | ||
code && "py-3 px-2 font-mono", | ||
italic && "italic", | ||
strikethrough && "line-through", | ||
underline && "underline", | ||
)} | ||
> | ||
{href ? ( | ||
<a | ||
href={href} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="hover:text-coolGray-500 dark:hover:text-coolGray-400" | ||
> | ||
{plain_text} | ||
</a> | ||
) : ( | ||
plain_text | ||
)} | ||
</span> | ||
); | ||
})} | ||
</> | ||
); | ||
}; | ||
|
||
const renderBlock = (block: Block) => { | ||
switch (block.type) { | ||
case "paragraph": | ||
return ( | ||
<p> | ||
<Text text={block["paragraph"].text} /> | ||
</p> | ||
); | ||
case "heading_1": | ||
return ( | ||
<h1> | ||
<Text text={block["heading_1"].text} /> | ||
</h1> | ||
); | ||
default: | ||
} | ||
}; | ||
|
||
export const Notion: FC<Props> = ({ blocks, content }) => { | ||
return ( | ||
<section className="px-3 text-black dark:text-white"> | ||
<div className="px-3 md:px-0 pb-3"> | ||
<h1 className="mb-4 text-3xl md:text-5xl lg:text-6xl font-bold tracking-tight text-warmGray-800 dark:text-white"> | ||
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */} | ||
{/* @ts-ignore */} | ||
{content.properties.Name?.title[0]?.plain_text} | ||
</h1> | ||
</div> | ||
<div className={s.notion}> | ||
{blocks.map(block => { | ||
return <Fragment key={block.id}>{renderBlock(block)}</Fragment>; | ||
})} | ||
</div> | ||
</section> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { Notion } from "./Notion"; | ||
export type { Props } from "./Notion"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
|
||
import { Client } from "@notionhq/client"; | ||
|
||
const notion = new Client({ | ||
auth: process.env.NOTION_API_KEY, | ||
}); | ||
|
||
export const getDatabase = async (databaseId: string) => { | ||
const response = await notion.databases.query({ | ||
database_id: databaseId, | ||
}); | ||
return response.results; | ||
}; | ||
|
||
export const getPage = async (pageId: string) => { | ||
const response = await notion.pages.retrieve({ page_id: pageId }); | ||
return response; | ||
}; | ||
|
||
export const getBlocks = async (blockId: string) => { | ||
const response = await notion.blocks.children.list({ block_id: blockId }); | ||
return response.results; | ||
}; |
Oops, something went wrong.
de39aa8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
storybook – ./
storybook-git-main-shunkakinoki.vercel.app
shunkakinoki-com.vercel.app
storybook.shunkakinoki.com
storybook-shunkakinoki.vercel.app
de39aa8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
shunkakinoki – ./
shunkakinoki.com
shunkakinoki-shunkakinoki.vercel.app
shunkakinoki-git-main-shunkakinoki.vercel.app
www.shunkakinoki.com