-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
85 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export async function getAllScrapList() { | ||
const response = await fetch( | ||
`https://api.notion.com/v1/databases/${process.env.NOTION_DATABASE_ID}/query`, | ||
{ | ||
method: "POST", | ||
headers: { | ||
Accept: "application/json", | ||
"Notion-Version": "2022-06-28", | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${process.env.NOTION_TOKEN}`, | ||
}, | ||
body: JSON.stringify({ page_size: 100 }), | ||
}, | ||
); | ||
const responseData = await response.json(); | ||
|
||
const targetData = responseData.results | ||
.map((item: any) => item.properties) | ||
.map((item: any) => { | ||
return { | ||
name: item.이름.title[0]?.plain_text || "", | ||
tags: item["다중 선택"].multi_select.map((tag: any) => tag.name), | ||
link: item.link.rich_text[0]?.plain_text || "", | ||
}; | ||
}); | ||
|
||
return targetData; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/app/home/components/scrap/scrap-item/scrap-item.stories.tsx
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,15 @@ | ||
import ScrapItem from "./scrap-item"; | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
|
||
const meta: Meta<typeof ScrapItem> = { | ||
title: "Home/ScrapItem", | ||
component: ScrapItem, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof ScrapItem>; | ||
|
||
export const Default: Story = { | ||
args: {}, | ||
}; |
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,33 @@ | ||
/** | ||
* 작성자: KYD | ||
* 기능: 홈페이지에 쓰일 스크랩 목록 (서버 컴포넌트) | ||
* 프로세스 설명: 프로세스 복잡시 노션링크 첨부권장 | ||
* 아이디어: 테이블 형태, 소팅, 노션으로 링크이동? | ||
*/ | ||
import { getAllScrapList } from "@/app/home/apis/scrap-apis"; | ||
|
||
interface IScrapItem {} | ||
|
||
const ScrapItem: React.FC<IScrapItem> = async () => { | ||
//SECTION HOOK호출 영역 | ||
const scrapList = await getAllScrapList(); | ||
//!SECTION HOOK호출 영역 | ||
|
||
//SECTION 상태값 영역 | ||
|
||
//!SECTION 상태값 영역 | ||
|
||
//SECTION 메서드 영역 | ||
|
||
//!SECTION 메서드 영역 | ||
|
||
return ( | ||
<div> | ||
{scrapList.map((item: any) => ( | ||
<div key={item.name}>{item.name}</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ScrapItem; |
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