Classes
LocalSource
Content source for local filesystem.
Reads markdown files from a directory, parsing frontmatter an…
LocalSource
Content source for local filesystem.
Reads markdown files from a directory, parsing frontmatter and generating content entries.
Configuration:
directory: str - Directory path (relative to site root)
glob: str - Glob pattern for matching files (default: "**/*.md")
exclude: list[str] - Patterns to exclude (default: [])
ContentSourceMethods 3
fetch_all
async
Fetch all content entries from this directory.
fetch_all
async async def fetch_all(self) -> AsyncIterator[ContentEntry]
Fetch all content entries from this directory.
Returns
AsyncIterator[ContentEntry]
fetch_one
async
Fetch a single file by relative path.
fetch_one
async async def fetch_one(self, id: str) -> ContentEntry | None
Fetch a single file by relative path.
Parameters 1
id |
str |
Relative path from directory (e.g., "getting-started.md") |
Returns
ContentEntry if found, None otherwiseContentEntry | None
—
get_last_modified
async
Get most recent modification time of any file.
get_last_modified
async async def get_last_modified(self) -> datetime | None
Get most recent modification time of any file.
Returns
Most recent mtime or Nonedatetime | None
—
Internal Methods 4
__init__
Initialize local source.
__init__
def __init__(self, name: str, config: dict[str, Any]) -> None
Initialize local source.
Parameters 2
name |
str |
Source name |
config |
dict[str, Any] |
Configuration with 'directory' key required |
_load_file
async
Load a single file into a ContentEntry.
_load_file
async async def _load_file(self, path: Path) -> ContentEntry | None
Load a single file into a ContentEntry.
Parameters 1
path |
Path |
Path to the file |
Returns
ContentEntry or None if file can't be readContentEntry | None
—
_should_exclude
Check if path should be excluded.
_should_exclude
def _should_exclude(self, path: Path) -> bool
Check if path should be excluded.
Parameters 1
path |
Path |
Full path to check |
Returns
True if path matches an exclude patternbool
—
_path_to_slug
Convert relative path to URL slug.
_path_to_slug
def _path_to_slug(self, rel_path: Path) -> str
Convert relative path to URL slug.
Parameters 1
rel_path |
Path |
Path relative to source directory |
Returns
URL-friendly slugstr
—
Functions
_parse_frontmatter
Parse YAML frontmatter from content.
_parse_frontmatter
def _parse_frontmatter(content: str) -> tuple[dict[str, Any], str]
Parse YAML frontmatter from content.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
content |
str |
— | Raw file content with optional frontmatter |
Returns
Tuple of (frontmatter dict, body content)tuple[dict[str, Any], str]
—