Skip to content
notion-to-mdx logo

Notion to MDX Converter

notion-to-mdx

Automatically converts Notion markdown exports to Next.js MDX format with proper metadata and formatting. Use this skill when working with Notion markdown files that need to be converted to page.mdx files in this Next.js repository. Handles title extraction, interactive dropdown creation, and aut...

mattnigh/skills_collection0installs24stars

SKILL.md

Full skill instructions

Notion to MDX Converter

Overview

This skill automates the conversion of Notion markdown exports into Next.js MDX-compatible format for this repository. It handles metadata extraction, formatting transformations, interactive conversion of expandable sections, and automatic downloading of images from Notion.

When to Use This Skill

Use this skill when:

  • Converting Notion markdown exports to page.mdx files in this repository
  • A file needs MDX frontmatter metadata added
  • Notion-specific markdown syntax needs to be transformed to Next.js MDX format
  • User mentions converting Notion content or asks to work with Notion markdown

Conversion Workflow

Step 1: Identify the Source File

When a user requests conversion of Notion markdown, identify the target file:

  • User may provide a file path directly
  • User may have a file open in their editor (check system reminders)
  • User may paste Notion markdown content directly

Step 2: Run the Conversion Script

Execute the conversion script with the appropriate file path:

python .claude/​skills/​notion-to-mdx/​scripts/​convert_notion_to_mdx.py <input_file> [output_file] [--page-id PAGE_ID]

Parameters:

  • <input_file>: Path to the Notion markdown file (required)
  • [output_file]: Optional output path (defaults to overwriting input file)
  • --page-id PAGE_ID: Optional Notion page ID for downloading images

Image Downloading: If --page-id is provided and NOTION_API_KEY is found in .env.local, the script will:

  • Detect Notion image attachments (format: ![text](attachment:UUID:filename))
  • Download images from Notion using the API
  • Save images to public/​images/​from-notion/ using the attachment ID as the filename
  • Update markdown references to point to local files

The script will:

  1. Download Notion images (if page ID provided)
  2. Extract the title from the first top-level heading (# Title)
  3. Add MDX frontmatter with the title metadata
  4. Identify bullet list sections and interactively prompt about expandable dropdowns

Step 3: Interactive Dropdown Conversion

The script will identify bullet list sections in the document and prompt the user:

--- Section 1 (lines 45-52) ---
- First bullet point
- Second bullet point
- Third bullet point

Convert this to expandable dropdown? (y/​n):

If the user responds 'y', the script prompts for summary text:

Enter the summary text (what appears when collapsed):

The script then converts the bullet list to:

<details>
  <summary>User's summary text</​summary>

- First bullet point
- Second bullet point
- Third bullet point
</​details>

Step 4: Verify the Output

After conversion, review the generated MDX file to ensure:

  • Title metadata is correct in the frontmatter
  • Expandable dropdowns are correctly formatted
  • Images are downloaded to public/​images/ and references are updated
  • File structure matches Next.js MDX requirements

Conversion Details

Title Extraction

The script extracts the title from the first top-level heading in the markdown:

# My Document Title

Content here...

Becomes:

---
title: "My Document Title"
---

# My Document Title

Content here...

If no top-level heading is found, defaults to "Untitled".

Expandable Dropdowns

Regular bullet lists in Notion exports appear as standard markdown bullets. The script identifies these sections and allows interactive conversion to HTML <details> elements:

Before (Notion bullet list):

- Point one
- Point two
- Point three

After (if converted to dropdown):

<details>
  <summary>Click to expand</​summary>

- Point one
- Point two
- Point three
</​details>

Image Downloading

When a Notion page ID is provided via --page-id, the script automatically downloads images embedded in the Notion export.

How it works:

  1. Script scans the markdown for Notion image attachments: ![alt](attachment:UUID:filename)
  2. Extracts the attachment IDs from the markdown
  3. Fetches blocks from the Notion page using the API
  4. Matches attachment IDs to find signed S3 URLs
  5. Downloads images to public/​images/​from-notion/
  6. Uses the attachment ID as the filename (keeping original extension)
  7. Updates markdown references to point to local files

Before (Notion attachment):

![image.png](attachment:6e9315e9-4f0f-4fec-82d9-28ef74260e5f:image.png)

After (local reference):

![image.png](/​public/​images/​from-notion/​6e9315e9-4f0f-4fec-82d9-28ef74260e5f.png)

Requirements:

  • Notion page must be shared with the integration (API key owner)
  • NOTION_API_KEY must be present in .env.local
  • Page ID can be extracted from Notion URL: notion.site/​Page-Title-{PAGE_ID}

Note: The script automatically searches for .env.local starting from the input file's directory up to the repository root.

Example Usage

User request: "Convert the Notion markdown in app/​my-post/​page.mdx and download the images"

Actions:

  1. Extract page ID from Notion URL (e.g., 1f82e4fe580280a29479cba5d8ffa898)
  2. Run: python .claude/​skills/​notion-to-mdx/​scripts/​convert_notion_to_mdx.py app/​my-post/​page.mdx --page-id 1f82e4fe580280a29479cba5d8ffa898
  3. Script automatically:
    • Finds NOTION_API_KEY in .env.local
    • Downloads images from Notion
    • Extracts title
    • Prompts user about bullet list sections for dropdown conversion
  4. User responds to prompts interactively
  5. File is updated with converted content and local image references

Example without images:

python .claude/​skills/​notion-to-mdx/​scripts/​convert_notion_to_mdx.py app/​my-post/​page.mdx

Example with images:

python .claude/​skills/​notion-to-mdx/​scripts/​convert_notion_to_mdx.py app/​my-post/​page.mdx --page-id 1f82e4fe580280a29479cba5d8ffa898

Non-Interactive Mode

To skip the interactive dropdown prompts (useful when no dropdowns are needed), modify the script call in code:

convert_notion_to_mdx(input_path, output_path, interactive=False)

This will perform title extraction only.

Resources

scripts/​convert_notion_to_mdx.py

Python script that performs the markdown-to-MDX conversion. Handles:

  • Notion image downloading via API
  • Title extraction from top-level headings
  • MDX frontmatter generation
  • Interactive dropdown creation with user prompts
  • Automatic .env.local discovery for API credentials

Dependencies: requests library for HTTP requests to Notion API

The script can be executed directly from the command line or imported as a Python module for programmatic use.

More skills from mattnigh

spring-framework-patterns logo
mattnigh/skills_collection

spring-framework-patterns

Comprehensive Spring Framework and Spring Boot best practices including dependency injection patterns, bean lifecycle and scopes, REST API development, Spring Data JPA, service layer design, Spring Security, testing strategies, caching, AOP, async processing, error handling, and common anti-patte...

24 0
View

TypeScript厳格モードによる型安全性設計を専門とするスキル。 📖 参照書籍: - 『Effective TypeScript』(Dan Vanderkam): 型設計 📚 リソース参照: - `resources/Level1_basics.md`: レベル1の基礎ガイド - `resources/Level2_intermediate.md`: レベル2の実務ガイド - `resources/Level3_advanced.md`: レベル3の応用ガイド - `resources/Level4_expert.md`: レベル4の専門ガイド - `resources/di...

24 0
View
deploying-cloud-k8s logo
mattnigh/skills_collection

deploying-cloud-k8s

Deploys applications to cloud Kubernetes (AKS/GKE/DOKS) with CI/CD pipelines. Use when deploying to production, setting up GitHub Actions, troubleshooting deployments. Covers build-time vs runtime vars, architecture matching, and battle-tested debugging.

24 0
View
moai-alfred-agent-guide logo
mattnigh/skills_collection

moai-alfred-agent-guide

19-agent team structure, decision trees for agent selection, Haiku vs Sonnet model selection, and agent collaboration principles. Use when deciding which sub-agent to invoke, understanding team responsibilities, or learning multi-agent orchestration.

24 0
View
mermaid-diagram-generator logo
mattnigh/skills_collection

mermaid-diagram-generator

Converts architecture descriptions, module specs, or workflow docs into Mermaid diagrams. Use when visualizing brick module relationships, workflows (DDD, investigation), or system architecture. Supports: flowcharts, sequence diagrams, class diagrams, state machines, entity relationship diagrams,...

24 0
View
pre-flight-check logo
mattnigh/skills_collection

pre-flight-check

INVOKE FIRST before any code work. Validates git workflow (branch, issue, worklog) and checks approach. Use at START of every task and END before completing. Prevents skipped steps.

24 0
View
browser-dev-tools logo
mattnigh/skills_collection

browser-dev-tools

This skill should be used when working with browser-rendered artifacts (i.e. Bun, React/React Native) to proactively validate that development work on localhost is being built appropriately and to support debugging browser-rendered content. Use this skill after making frontend changes to verify t...

24 0
View
lead-dev logo
mattnigh/skills_collection

lead-dev

Lead Développeur - Coordination technique opérationnelle, code review, mentoring et livraison. Pair de web-dev-process au niveau OPÉRATIONS.

24 0
View
worker-monitor logo
mattnigh/skills_collection

worker-monitor

Monitor Docker workers, RQ queue health, and auto-scale workers (max 4). Use when: checking job progress, monitoring queue depth, scaling workers up/down, diagnosing slow processing, or waiting for jobs to complete. Referenced by data-quality skill during reprocessing.

24 0
View
quality-advisor logo
mattnigh/skills_collection

quality-advisor

Proactive quality guidance system that monitors artifact creation and provides real-time feedback on documentation quality

24 0
View
bump-version logo
mattnigh/skills_collection

bump-version

This skill should be used when the user wants to bump the version number in the workspace. It updates versions across all pyproject.toml files (root, tde, and tda packages) and the CHANGELOG.md to keep them synchronized.

24 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View