@@ -12,10 +12,10 @@ const __dirname = dirname(__filename);
12
12
dotenv . config ( { path : resolve ( __dirname , '../.env.local' ) } ) ;
13
13
14
14
// 페이지 ID
15
- const PAGE_ID = '76318ec3-9f83-4cc2-af54-7d81daab0131 ' ;
15
+ const PAGE_ID = '2149c6bf2b17802a9b75db1f01b9cbe7 ' ;
16
16
17
- // ? using this script : pnpx tsx scripts/fetchNotionProperties .ts
18
- async function fetchNotionPage ( ) {
17
+ // ? using this script : pnpx tsx scripts/fetchNotionBlocks .ts
18
+ async function fetchAndSaveBlocks ( ) {
19
19
try {
20
20
// Notion API 키 확인
21
21
let apiKey = process . env . NOTION_API_KEY ;
@@ -45,24 +45,26 @@ async function fetchNotionPage() {
45
45
process . exit ( 1 ) ;
46
46
}
47
47
48
- console . log ( 'Notion API에서 페이지 속성 데이터를 가져오는 중...' ) ;
48
+ console . log ( 'Notion API에서 블록 데이터를 가져오는 중...' ) ;
49
49
50
50
// Notion 클라이언트 생성
51
51
const client = new Client ( { auth : apiKey } ) ;
52
52
53
+ // 페이지 블록 가져오기
53
54
const blocks = await client . getPageBlocks ( PAGE_ID ) ;
54
-
55
55
// JSON 파일로 저장
56
56
const outputPath = join ( __dirname , '../src/sample-data/notionPage.json' ) ;
57
57
console . log ( `저장 경로: ${ outputPath } ` ) ;
58
58
writeFileSync ( outputPath , JSON . stringify ( blocks , null , 2 ) , 'utf8' ) ;
59
59
60
- console . log ( `페이지 데이터가 성공적으로 저장되었습니다: ${ outputPath } ` ) ;
60
+ console . log ( `블록 데이터가 성공적으로 저장되었습니다: ${ outputPath } ` ) ;
61
+ console . log ( `총 ${ blocks . length } 개의 블록을 가져왔습니다.` ) ;
62
+ process . exit ( 0 ) ;
61
63
} catch ( error ) {
62
- console . error ( '페이지 데이터 가져오기 실패:' , error ) ;
64
+ console . error ( '블록 데이터 가져오기 실패:' , error ) ;
63
65
process . exit ( 1 ) ;
64
66
}
65
67
}
66
68
67
69
// 스크립트 실행
68
- fetchNotionPage ( ) ;
70
+ fetchAndSaveBlocks ( ) ;
0 commit comments