PhoenixKit.Modules.Sitemap.Sources.Static (phoenix_kit v1.7.196)

Copy Markdown View Source

Static routes source for sitemap generation.

Collects configurable static routes for the sitemap. Routes are configured through Settings and resolved via RouteResolver - NO hardcoded fallbacks.

Settings

  • sitemap_static_routes - JSON array of route configurations
  • sitemap_custom_urls - JSON array of custom URL entries

Route Configuration Format

Each route in sitemap_static_routes can have:

%{
  "plug" => "PhoenixKitWeb.Users.Registration",  # Module to resolve via RouteResolver
  "path" => "/custom/path",                       # OR explicit path (overrides plug)
  "priority" => 0.7,                              # Sitemap priority (0.0-1.0)
  "changefreq" => "monthly",                      # Change frequency
  "title" => "Register",                          # Display title
  "category" => "Authentication",                 # Category for grouping
  "prefixed" => true                              # Use PhoenixKit URL prefix
}

Custom URL Format

Each entry in sitemap_custom_urls:

%{
  "path" => "/about-us",
  "priority" => 0.8,
  "changefreq" => "monthly",
  "title" => "About Us",
  "category" => "Company"
}

Default Configuration

By default, includes:

  • Homepage (/) - Priority: 0.9, daily
  • Registration page - Priority: 0.7, monthly (if route exists)
  • Login page - Priority: 0.7, monthly (if route exists)

No Hardcoded Fallbacks

If RouteResolver cannot find a route and no explicit path is configured, the route is skipped. This ensures sitemap only contains valid URLs.

Summary

Functions

Returns the built-in default static routes (always includes the homepage).

Functions

default_static_routes()

@spec default_static_routes() :: [map()]

Returns the built-in default static routes (always includes the homepage).

These apply whenever sitemap_static_routes is unset. Once that setting is saved (even as an empty list), it replaces this list entirely — so saving [] removes the homepage entry too. Exposed so the settings UI can pre-fill the editor with the current effective routes instead of an empty list that looks safe to submit as-is but isn't.