Content Mapper

Map website URLs to local source files using direct, slug, or limax strategies.

source

url_to_relpath


def url_to_relpath(
    url:str, # Full page URL
    base_path:str, # Local base directory
    site_url:str, # Site base URL to strip
)->pathlib.Path | None:

Convert a page URL to a relative local path, stripping site URL and .html suffix.


source

find_source_file


def find_source_file(
    rel_path:Path, # Relative path without extension
    exts:tuple=('.qmd', '.md', '.ipynb', '.mdx', '.astro'), # Extensions to try in order
)->str | None:

Find first existing source file matching the path with any of the given extensions.


source

url_to_file_path


def url_to_file_path(
    url:str, # Full page URL
    base_path:str, # Local base directory
    site_url:str, # Site base URL
)->str | None:

Map a website URL to its local source file path.


source

build_limax_slug_index


def build_limax_slug_index(
    base_path:str, # Local base directory
)->dict:

Build slug→filepath index using Node/limax transliteration for Arabic Astro sites.


source

build_slug_index


def build_slug_index(
    base_path:str, # Local base directory
)->dict:

Build slug→filepath index by reading slug field from frontmatter of all source files.


source

map_all_urls_to_files


def map_all_urls_to_files(
    base_path:str, # Local base directory
    site_url:str, # Site base URL
    urls:list, # List of page URLs to map
    mode:str='direct', # One of: 'direct', 'slug', 'limax'
    normalize:bool=False, # Normalize URLs before mapping
)->dict:

Map page URLs to local source file paths using the specified strategy.