# `PhoenixKit.Modules.Sitemap.Sources.RouterDiscovery`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.87/lib/modules/sitemap/sources/router_discovery.ex#L1)

Router Discovery source for sitemap generation.

Automatically scans all GET routes from the parent application's router
and includes them in the sitemap. Routes can be filtered using exclude
patterns and include-only patterns.

## Settings

- `sitemap_router_discovery_enabled` - Enable/disable auto-discovery (default: true)
- `sitemap_router_discovery_exclude_patterns` - JSON array of regex patterns to exclude
- `sitemap_router_discovery_include_only` - JSON array of regex patterns for whitelist mode
- `sitemap_protected_pipelines` - JSON array of pipeline names that require authentication

## Default Exclusions

By default, the following patterns are excluded:
- `^/admin` - Admin routes
- `^/api` - API endpoints
- `^/phoenix_kit` - PhoenixKit admin routes
- `^/dev` - Development routes
- `:[a-z_]+` - Routes with parameters
- `\*` - Wildcard routes

Additionally, routes using authentication pipelines are automatically excluded:
- `:phoenix_kit_require_authenticated` - Routes requiring user authentication
- `:phoenix_kit_admin_only` - Routes requiring admin/owner role
- `:authenticated` - Common name for authentication pipeline
- `:require_authenticated` - Alternative authentication pipeline name
- `:admin` - Common admin pipeline name
- `:admin_only` - Alternative admin pipeline name

Custom pipelines can be added via `sitemap_protected_pipelines` setting.

LiveView routes using authentication `on_mount` hooks are also excluded:
- `{PhoenixKitWeb.Users.Auth, :phoenix_kit_ensure_authenticated_scope}` - Ensures user is authenticated
- `{PhoenixKitWeb.Users.Auth, :phoenix_kit_redirect_if_authenticated_scope}` - Redirects if already authenticated

## Examples

    # Enable auto-discovery (default)
    Settings.update_boolean_setting("sitemap_router_discovery_enabled", true)

    # Custom exclude patterns
    Settings.update_setting("sitemap_router_discovery_exclude_patterns",
      Jason.encode!(["^/admin", "^/api", "^/private"]))

    # Whitelist mode - only include specific paths
    Settings.update_setting("sitemap_router_discovery_include_only",
      Jason.encode!(["^/products", "^/categories"]))

    # Custom protected pipelines (add to defaults)
    Settings.update_setting("sitemap_protected_pipelines",
      Jason.encode!(["my_auth_pipeline", "member_only"]))

## Sitemap Properties

- Priority: 0.5 (default for discovered routes)
- Change frequency: weekly
- Category: "Routes"

---

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