npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hansolbangul/notion-api

v0.0.4

Published

A lightweight library for fetching and statically generating data and TypeScript types from Notion pages.

Downloads

275

Readme

@hansolbangul/notion-api

@hansolbangul/notion-api는 Notion의 데이터를 정적으로 가져오고 TypeScript 타입을 생성하기 위한 가벼운 라이브러리입니다. React, Next.js, 정적 사이트 생성기 등 다양한 프로젝트에서 유용하게 사용할 수 있습니다.

주요 기능

  • Notion 데이터 가져오기: Notion API를 통해 테이블 형태의 데이터를 가져옵니다.
  • TypeScript 타입 생성: CLI를 통해 Notion 테이블의 스키마를 읽어 TypeScript 타입을 자동 생성합니다.
  • 간단한 통합: 최소한의 설정으로 동작하며, 커스터마이징 가능합니다.

설치 방법

npm

npm install @hansolbangul/notion-api

yarn

yarn add @hansolbangul/notion-api

pnpm

pnpm add @hansolbangul/notion-api

사용 방법

1. 라이브러리로 데이터 가져오기

import NotionApiService from '@hansolbangul/notion-api';

const notionService = new NotionApiService({
  pageId: 'your-notion-page-id', // Notion 테이블의 ID를 입력하세요
});

(async () => {
  const data = await notionService.getPosts();
  console.log(data);
})();

2. CLI로 TypeScript 타입 생성하기

이후 CLI나 Script를 실행하여 타입을 생성합니다.

타입을 생성할때의 Notion의 형태는 아래와 같은 형태를 유지해야 합니다. image 템플릿 저장하기

npx type-cli <PAGE_ID>
"script": {
    "notion-type": "type-cli <PAGE_ID>"
}

생성된 타입은 src/types.d.ts 파일에 저장됩니다:

interface NotionProperties {
    date: { type: string; start_date: string };
    thumbnail: { url: string }[];
    type: ("Library" | "Project" | "Post" | "Page")[];
    slug: string;
    tags: ("Ice Break" | "Develop" | "Open Source" | "Daily" | "SEO" | "Blog" | "Next.js" | "GraphQL" | "Git" | "CSS" | "Apollo" | "Docs" | "DDD" | "Architecture" | "React" | "코딩테스트[lv.2]" | "코딩테스트[lv.3]" | "Emotion" | "F12" | "Javascript" | "Toss" | "SCSS" | "Recoil" | "Typescript" | "Project" | "Jest" | "TestCode" | "Recommend" | "React-Query" | "Suspense" | "Monorepo" | "Review" | "Styled-Component" | "Browser" | "Render" | "Library" | "Promise" | "Hook" | "Model" | "PackageManager" | "Npm" | "Yarn" | "TurboRepo" | "Pnpm" | "Bundler" | "Msw" | "Zustand" | "Bun" | "HOC" | "Class" | "This" | "Reconciliation" | "Modal" | "Swiper" | "Debounce" | "Throttle" | "Protal" | "Utterances" | "SSG" | "Component" | "Three.js" | "CodingTest" | "Set" | "IntersectionObserver" | "EventBus" | "TypeSafety" | "Module" | "Pattern" | "ISR")[];
    summary: string;
    updatedAt: string;
    author: { id: string; name: string; profile_photo: string }[];
    title: string;
    status: ("Private" | "Public")[];
}

주요 API

NotionApiService 클래스

constructor(config: NotionConfig)

  • config.pageId : Notion 테이블 페이지 ID를 설정합니다.

getPosts<T>(viewId?: string): Promise<T>

  • Notion 페이지에서 데이터를 가져옵니다. 반환 데이터는 스키마에 따라 구조화됩니다.

기여하기

기여를 환영합니다! 버그 리포트나 기능 요청은 이슈 페이지에 등록해주세요.


라이선스

이 프로젝트는 ISC 라이선스를 따릅니다. 상세한 내용은 LICENSE 파일을 참조하세요.