[Discussion] Notion To MD v4: Media Handler Technical Details #115
souvikinator
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Media Handler Technical Documentation
Overview
The Media Handler module serves as a crucial component in the notion-to-md pipeline, processing and managing all media-related content after the Block Fetcher completes its work. With the introduction of the builder pattern in v4, the configuration and setup have become more intuitive and flexible while maintaining the core functionality.
High Level Overview
Core Responsibilities
Configuration Using Builder Pattern
The new builder pattern provides a more intuitive way to configure media handling. Here's how the configuration system is structured:
Base Configuration
Media Strategy Configuration
The builder pattern introduces three distinct methods for configuring media handling strategies:
Strategy Requirements
Each strategy has specific requirements that must be met:
Download
strategy requires:outputPath
: Destination directory for media filestransformPath
: Function to customize media URLspreserveExternalUrls
: Boolean to control external URL handlingUpload
strategy requires:uploadHandler
: Async function to handle media uploadscleanupHandler
: Function to manage file cleanuptransformPath
: Function to modify URLs post-uploadpreserveExternalUrls
: Boolean to control external URL handlingDirect
strategy (useNotionUrls):Low Level Design
Media Manifest System
The Media Handler maintains a manifest file for each page to track media assets and their relationships to blocks. The manifest helps with:
Manifest Structure
Implementation Examples
1. Static Site Generator Implementation
2. Cloud Storage Implementation
3. Preview/Temporary Content Implementation
Beta Was this translation helpful? Give feedback.
All reactions