Skip to content

aoracle/notion-integration-framework

Repository files navigation

Notion Integration Framework

A powerful Node.js framework for seamlessly adding content to Notion pages and databases with support for markdown parsing, smart toggles, and flexible formatting options.

🚀 Features

  • Universal URL Support: Works with any Notion page or database URL
  • Smart Toggle Creation: Automatically creates collapsible sections for long content
  • Markdown Parsing: Full markdown support with code blocks, lists, and formatting
  • CLI Tool: Easy command-line interface for quick additions
  • Flexible Content: Add text, files, or stdin input
  • Auto-detection: Automatically detects if URL is a page or database
  • Customizable: Control timestamps, formatting, and toggle behavior

📦 Installation

# Clone the repository
git clone https://github.com/yourusername/notion-integration-framework.git
cd notion-integration-framework

# Install dependencies
npm install

🔧 Setup

  1. Get your Notion API token from Notion Developers
  2. Update the NOTION_TOKEN in notion-notes-framework.js
  3. Ensure the token has access to your target pages/databases

📝 Usage

Basic Usage

# Add simple text
node add-to-notion.js "https://notion.so/your-page" "Your content here"

# Add from a file
node add-to-notion.js "https://notion.so/your-page" ./document.md

# Add from stdin
cat document.md | node add-to-notion.js "https://notion.so/your-page" --stdin

Advanced Options

# Add with custom title
node add-to-notion.js "url" "content" --title "My Custom Title"

# Add with smart toggles (auto-detect from headers)
node add-to-notion.js "url" file.md --toggles

# Customize toggle threshold
node add-to-notion.js "url" file.md --toggles --min-toggle-lines 15

# Disable timestamp
node add-to-notion.js "url" "content" --no-timestamp

# Disable markdown parsing
node add-to-notion.js "url" "content" --no-markdown

Programmatic Usage

const NotionNotesFramework = require('./notion-notes-framework');

const framework = new NotionNotesFramework();

// Simple text
await framework.addNotes(
  'https://notion.so/your-page-url',
  'Your content here',
  { title: 'My Note' }
);

// With toggles
await framework.addNotes(
  'https://notion.so/your-page-url',
  markdownContent,
  { 
    title: 'Documentation',
    useToggles: true,
    toggleSections: 'auto',
    minToggleLines: 10
  }
);

🎯 Smart Toggles

The framework intelligently creates collapsible sections:

  • Short sections (< 10 lines): Display as regular headers
  • Long sections (≥ 10 lines): Create collapsible toggles
  • Customizable threshold: Adjust based on your needs

📋 Supported Content

Markdown Elements

  • Headers (#, ##, ###)
  • Lists (bullet and numbered)
  • Code blocks with syntax highlighting
  • TODO items
  • Horizontal rules
  • Bold and italic text

Notion Blocks

  • Headings (1-3)
  • Paragraphs
  • Toggle lists
  • Code blocks
  • Bulleted lists
  • Numbered lists
  • To-do items
  • Dividers
  • Callouts

🛠️ Project Structure

notion-integration-framework/
├── notion-notes-framework.js    # Core framework
├── add-to-notion.js            # CLI tool
├── claude-notion-integration.js # Original integration
├── test-notion-framework.js    # Test examples
├── test-toggles.js            # Toggle feature tests
├── package.json               # Dependencies
└── README.md                  # This file

🧪 Examples

Meeting Notes

node add-to-notion.js "notion-url" meeting-notes.md --title "Team Meeting" --toggles

Documentation

node add-to-notion.js "notion-url" api-docs.md --toggles --min-toggle-lines 20

Quick Notes

echo "Remember to review PR #123" | node add-to-notion.js "notion-url" --stdin --title "Quick Reminder"

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

MIT License - see LICENSE file for details

🔗 Links


Made with ❤️ for the Notion community

About

A flexible framework for adding content to Notion with markdown support and smart toggles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published