Search documentation of phoenix_kit

# PhoenixKit.Sitemap.Sources.Entities (phoenix_kit v1.6.19)

View Source

Entities source for sitemap generation.

Collects published entity records from the PhoenixKit Entities system. Each entity can define its own URL pattern in settings, and individual records can be excluded via metadata.

## Universal Entity Support

This source automatically collects ALL published entities regardless of their name. By default, auto-pattern generation is enabled (`sitemap_entities_auto_pattern: true`), which means every entity with published records will be included in the sitemap.

## URL Pattern Resolution

URL patterns are resolved using fallback chain:

1. Entity-specific override: `entity.settings["sitemap_url_pattern"]`
2. Router Introspection: automatic detection from parent app router
3. Per-entity Settings: `sitemap_entity_{name}_pattern`
4. Global Settings: `sitemap_entities_pattern`
5. Auto-generated fallback: `/:entity_name/:slug` (if `sitemap_entities_auto_pattern` is true)

Pattern variables:

- `:slug` - Record slug
- `:id` - Record ID
- `:entity_name` - Entity name (for global pattern)

## Examples

    # Entity settings override (highest priority):
    # entity.settings = %{"sitemap_url_pattern" => "/blog/:slug"}
    # Generates: /blog/my-article

    # Router auto-detection (if parent app has route):
    # live "/pages/:slug", PagesLive, :show
    # Entity "page" generates: /pages/my-article

    # Settings override:
    # sitemap_entity_page_pattern = "/content/:slug"
    # Entity "page" generates: /content/my-article

    # Auto-generated fallback (enabled by default):
    # Entity "hydraulic_cylinder" generates: /hydraulic_cylinder/my-product
    # Entity "contact_request" generates: /contact_request/request-123

## Index Pages

By default, index/list pages are included for each entity (e.g., `/page`, `/products`). This can be controlled via the `sitemap_entities_include_index` setting (default: true).

Index path resolution:

1. Entity settings: `entity.settings["sitemap_index_path"]`
2. Router Introspection: automatic detection (e.g., `/page` or `/pages`)
3. Per-entity Settings: `sitemap_entity_{name}_index_path`
4. Auto-generated fallback: `/:entity_name` (if `sitemap_entities_auto_pattern` is true)

## Configuration

- `sitemap_entities_auto_pattern` - Enable auto URL pattern generation (default: true)
- `sitemap_entities_include_index` - Include entity index pages (default: true)
- `sitemap_entity_{name}_pattern` - Per-entity URL pattern override
- `sitemap_entity_{name}_index_path` - Per-entity index page path override
- `sitemap_entities_pattern` - Global pattern template (e.g., "/:entity_name/:slug")

## Exclusion

Records can be excluded by setting `record.metadata["sitemap_exclude"] = true`.

## Sitemap Properties

Records:

- Priority: 0.8 (high priority for entity content)
- Change frequency: weekly
- Category: Entity display name
- Last modified: Record's date_updated timestamp

Index pages:

- Priority: 0.7
- Change frequency: daily
- Category: Entity display name
- Last modified: Entity's updated_at timestamp