# Content Mapper


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

------------------------------------------------------------------------

<a
href="https://github.com/abdelkareemkobo/seo_rat/blob/main/seo_rat/content_mapper.py#L20"
target="_blank" style="float:right; font-size:smaller">source</a>

### url_to_relpath

``` python

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.*

------------------------------------------------------------------------

<a
href="https://github.com/abdelkareemkobo/seo_rat/blob/main/seo_rat/content_mapper.py#L29"
target="_blank" style="float:right; font-size:smaller">source</a>

### find_source_file

``` python

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.*

------------------------------------------------------------------------

<a
href="https://github.com/abdelkareemkobo/seo_rat/blob/main/seo_rat/content_mapper.py#L41"
target="_blank" style="float:right; font-size:smaller">source</a>

### url_to_file_path

``` python

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.*

------------------------------------------------------------------------

<a
href="https://github.com/abdelkareemkobo/seo_rat/blob/main/seo_rat/content_mapper.py#L51"
target="_blank" style="float:right; font-size:smaller">source</a>

### build_limax_slug_index

``` python

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

```

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

------------------------------------------------------------------------

<a
href="https://github.com/abdelkareemkobo/seo_rat/blob/main/seo_rat/content_mapper.py#L82"
target="_blank" style="float:right; font-size:smaller">source</a>

### build_slug_index

``` python

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.*

------------------------------------------------------------------------

<a
href="https://github.com/abdelkareemkobo/seo_rat/blob/main/seo_rat/content_mapper.py#L104"
target="_blank" style="float:right; font-size:smaller">source</a>

### map_all_urls_to_files

``` python

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.*
