Behaviour for sitemap data sources.
Each source module must implement this behaviour to provide URL entries for sitemap generation.
Required Callbacks
source_name/0- Unique atom identifier for the sourceenabled?/0- Whether this source is activecollect/1- Collect URL entries from this source
Optional Callbacks
sitemap_filename/0- Custom filename for the module's sitemap filesub_sitemaps/1- Split into multiple sub-sitemap files (e.g., per-blog, per-entity-type)
Summary
Callbacks
Collects all URL entries from this source.
Checks if this source is enabled and should be included in sitemap.
Returns the base filename for this source's sitemap file (without .xml extension).
Returns the unique name/identifier for this source.
Returns a list of sub-sitemaps for sources that produce multiple files.
Functions
Returns the sitemap filename for a source module.
Returns sub-sitemaps for a source module, or nil if not implemented.
Safely collects entries from a source, handling errors gracefully.
Helper function to check if a source module is valid.
Callbacks
@callback collect(opts :: keyword()) :: [PhoenixKit.Modules.Sitemap.UrlEntry.t()]
Collects all URL entries from this source.
@callback enabled?() :: boolean()
Checks if this source is enabled and should be included in sitemap.
@callback sitemap_filename() :: String.t()
Returns the base filename for this source's sitemap file (without .xml extension).
Default: "sitemap-#{source_name()}"
@callback source_name() :: atom()
Returns the unique name/identifier for this source.
@callback sub_sitemaps(opts :: keyword()) :: [{String.t(), [PhoenixKit.Modules.Sitemap.UrlEntry.t()]}] | nil
Returns a list of sub-sitemaps for sources that produce multiple files.
Return nil for a single file, or a list of {group_name, entries} tuples
for per-group splitting (e.g., per-blog, per-entity-type).
Each group will be saved as sitemap-{source}-{group_name}.xml.
Functions
Returns the sitemap filename for a source module.
Calls the optional sitemap_filename/0 callback if implemented,
otherwise returns "sitemap-#{source_name()}".
@spec get_sub_sitemaps( module(), keyword() ) :: [{String.t(), [PhoenixKit.Modules.Sitemap.UrlEntry.t()]}] | nil
Returns sub-sitemaps for a source module, or nil if not implemented.
@spec safe_collect( module(), keyword() ) :: [PhoenixKit.Modules.Sitemap.UrlEntry.t()]
Safely collects entries from a source, handling errors gracefully.
Helper function to check if a source module is valid.