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

markdown2notion

v1.2.1

Published

Convert markdown files to notion database. The folder structure is also fully represented as tags in notion.

Downloads

14

Readme

markdown2notion

npm version License: MIT codecov

Convert markdown files to notion database. The folder structure is also fully represented as tags in notion.

Please refer to here for how to issue notion token and how to link with DB.

🔗 Links

日本語の説明書👉JP-README.md

🔽 Installation

npm install markdown2notion
yarn add markdown2notion

🔧 Usage

javascript and typescript are supported.

markdownToNotion()

import {markdownToNotion} from 'markdown2notion'

async function main(){
    try{
        await markdownToNotion(
        'notion token',
        'notion database id', 
        'markdown folder path', 
        'Column of notion displaying file names. Default is Title', 
        'Column of notion displaying folder name as tag. Default is Tags'
        )
    } catch (error) {
        console.error(error);
    }
}

searchPage()

Since the URL of the page changes every time you use markdownToNotion(), if you want to do something with the URL, please use this function to get the URL of the page.

import {searchPage} from 'markdown2notion'

async function main(){
  try{
      const result = await searchPage(
      'notion token',
      'notion database id', 
      'Column of notion displaying file names. Default is Title', 
      'Column of notion displaying folder name as tag. Default is Tags',
      'search file name',
      'search tags name array'
      )
      // If files with the same filename exist, multiple pages are returned.
      console.log(result)// The object of the notion page is returned. url can be taken from result['results'][0]['url'] or something like that.
  } catch (error) {
      console.error(error);
  }
}

🔰 Example

🔽markdownToNotion()

markdown folder structure

├── docs
│   ├── sample1
│   │   ├── sample1_1
│   │   │   ├── sampleContent1_1.md
│   │   ├── sampleContent1.md
│   ├── sample2
│   │   ├── sampleContent2.md
├── src
│   ├── index.ts
├── .env

notion DB

markdown files

Sample Markdown Folder

index.ts

import {markdownToNotion} from 'markdown2notion'
import * as dotenv from 'dotenv'

async function main() {
    dotenv.config()
    const token = process.env.NOTION_TOKEN
    const databaseId = process.env.NOTION_DATABASE_ID
    try {
      await markdownToNotion(token, databaseId, 'docs', 'Title', 'Tags');
    } catch (error) {
      console.error(error);
    }
}

main()

.env

NOTION_TOKEN=secret_xxxxxxxxxxxxxx
NOTION_DATABASE_ID=xxxxxxxxxxxxxxx

Result

The folder name becomes a tag.

Filtering using tags makes it easier to access specific files.

🔽searchPage()

index.ts

import {searchPage} from 'markdown2notion'
import * as dotenv from 'dotenv'

async function main() {
    dotenv.config()
    const token = process.env.NOTION_TOKEN
    const databaseId = process.env.NOTION_DATABASE_ID
    const title = 'sampleContent1_1';
    const tags = ['sample1_1'];

    try {
      const result = await searchPage(token, databaseId, 'Title', 'Tags', title, tags);
      console.log(result['results'][0]['url']);
    } catch (error) {
      console.error('Error searching for page:', error);
    }
}

main()

result

{
  object: 'list',
  results: [
    {
      object: 'page',
      id: '33.....',
      created_time: '2023-03-29T14:15:00.000Z',
      last_edited_time: '2023-03-29T14:15:00.000Z',
      created_by: [Object],
      last_edited_by: [Object],
      cover: null,
      icon: null,
      parent: [Object],
      archived: false,
      properties: [Object],
      url: 'https://www.notion.so/sampleContent1_1-33...'
    }
  ],
  next_cursor: null,
  has_more: false,
  type: 'page',
  page: {}
}

License

MIT