Module

content_layer.loaders

Content loader factory functions.

These are the user-facing functions for creating content sources. They provide a clean API and handle lazy loading of dependencies.

Usage:

from bengal.content_layer import local_loader, github_loader

collections = {
    "docs": define_collection(schema=Doc, loader=local_loader("content/docs")),
    "api": define_collection(schema=API, loader=github_loader(repo="org/api")),
}

Functions

local_loader
Create a local filesystem content loader.
1 ContentSource
def local_loader(directory: str | Path) -> ContentSource

Create a local filesystem content loader.

Parameters 1

Name Type Default Description
directory str | Path

Path to content directory (relative to site root)

Returns

ContentSource

LocalSource instance

github_loader
Create a GitHub repository content loader. Fetches markdown files from a GitHub repository. Suppor…
1 ContentSource
def github_loader(repo: str) -> ContentSource

Create a GitHub repository content loader.

Fetches markdown files from a GitHub repository. Supports both public and private repositories (with token).

Parameters 1

Name Type Default Description
repo str

Repository in "owner/repo" format

Returns

ContentSource

GitHubSource instance

Requires:

pip install bengal[github]

rest_loader
Create a REST API content loader. Fetches content from any REST API that returns JSON.
1 ContentSource
def rest_loader(url: str) -> ContentSource

Create a REST API content loader.

Fetches content from any REST API that returns JSON.

Parameters 1

Name Type Default Description
url str

API endpoint URL

Returns

ContentSource

RESTSource instance

Requires:

pip install bengal[rest]  # includes aiohttp

notion_loader
Create a Notion database content loader. Fetches pages from a Notion database and converts them to…
1 ContentSource
def notion_loader(database_id: str) -> ContentSource

Create a Notion database content loader.

Fetches pages from a Notion database and converts them to markdown.

Parameters 1

Name Type Default Description
database_id str

Notion database ID (from URL or API)

Returns

ContentSource

NotionSource instance

Requires:

pip install bengal[notion]

Setup:

1. Create integration at https://www.notion.so/my-integrations
2. Share database with the integration
3. Set NOTION_TOKEN env var or pass token parameter