# `PhoenixKit.Modules.Sitemap.FileStorage`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.165/lib/modules/sitemap/file_storage.ex#L1)

File-based storage for sitemap XML files.

Supports both a single index file and per-module sitemap files:

    priv/static/sitemap.xml                     -> sitemapindex (index)
    priv/static/sitemaps/sitemap-static.xml     -> static pages
    priv/static/sitemaps/sitemap-routes.xml     -> router discovery
    priv/static/sitemaps/sitemap-publishing.xml -> publishing posts
    priv/static/sitemaps/sitemap-shop.xml       -> shop products
    priv/static/sitemaps/sitemap-entities.xml   -> entity records

## Key Features

- **Direct nginx serving** - Files in priv/static/ can be served without Phoenix
- **ETag from mtime** - Use `get_file_stat/0` for cache validation
- **On-demand generation** - First request generates if file missing
- **Per-module files** - Independent generation and caching per source

# `clear_all`

```elixir
@spec clear_all() :: :ok
```

Clears the sitemap file. Alias for `delete/0`.

# `delete`

```elixir
@spec delete() :: :ok
```

Deletes the sitemap file to force regeneration.

# `delete_all_modules`

```elixir
@spec delete_all_modules() :: :ok
```

Deletes all module sitemap files in the sitemaps subdirectory.

# `delete_module`

```elixir
@spec delete_module(String.t()) :: :ok
```

Deletes a specific module sitemap file.

# `exists?`

```elixir
@spec exists?() :: boolean()
```

Checks if the sitemap file exists.

# `file_path`

```elixir
@spec file_path() :: String.t()
```

Returns the file path for the sitemap.

# `get_file_stat`

```elixir
@spec get_file_stat() :: {:ok, tuple(), non_neg_integer()} | :error
```

Returns file stats for ETag generation.

# `get_module_stat`

```elixir
@spec get_module_stat(String.t()) :: {:ok, tuple(), non_neg_integer()} | :error
```

Returns file stats for a specific module sitemap file.

# `index_exists?`

```elixir
@spec index_exists?() :: boolean()
```

Checks if the index sitemap file exists.

# `list_module_files`

```elixir
@spec list_module_files() :: [String.t()]
```

Lists all `.xml` files in the sitemaps subdirectory.

Returns list of filenames without the `.xml` extension.

# `load`

```elixir
@spec load() :: {:ok, String.t()} | :error
```

Loads XML content from the sitemap file.

# `load_index`

```elixir
@spec load_index() :: {:ok, String.t()} | :error
```

Loads XML content from the index sitemap file.

# `load_module`

```elixir
@spec load_module(String.t()) :: {:ok, String.t()} | :error
```

Loads XML content for a specific module sitemap file.

# `module_exists?`

```elixir
@spec module_exists?(String.t()) :: boolean()
```

Checks if a specific module sitemap file exists.

# `module_file_path`

```elixir
@spec module_file_path(String.t()) :: String.t()
```

Returns the full path for a module sitemap file.

# `save`

```elixir
@spec save(String.t()) :: :ok | {:error, term()}
```

Saves XML content to the sitemap file.

Creates the storage directory if it doesn't exist.

# `save_index`

```elixir
@spec save_index(String.t()) :: :ok | {:error, term()}
```

Saves XML content to the index sitemap file.

# `save_module`

```elixir
@spec save_module(String.t(), String.t()) :: :ok | {:error, term()}
```

Saves XML content for a specific module sitemap file.

Filename should NOT include the `.xml` extension.

## Examples

    FileStorage.save_module("sitemap-shop", xml_content)
    # Saves to priv/static/sitemaps/sitemap-shop.xml

# `sitemaps_dir`

```elixir
@spec sitemaps_dir() :: String.t()
```

Returns the path to the sitemaps subdirectory.

# `storage_dir`

```elixir
@spec storage_dir() :: String.t()
```

Returns the storage directory path.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
