PhoenixKit.Modules.Publishing.Web.Controller.SlugResolution (PhoenixKitPublishing v0.2.0)

Copy Markdown View Source

URL slug resolution for the publishing controller.

Handles resolving URL slugs to internal slugs, including:

  • Per-language custom URL slugs
  • Previous URL slugs for 301 redirects
  • DB-based slug lookups

Summary

Functions

Builds a 301 redirect URL from a resolved post map.

Resolves URL slug to internal slug using cache/DB.

Resolves a URL slug to the internal post slug. Used by versioned URL handler and other places that need the internal slug.

Functions

build_post_redirect_url(group_slug, cached_post, language, url_slug)

Builds a 301 redirect URL from a resolved post map.

Accepts both the cache-shaped map (carries :mode/:date/:time/:language_slugs) and the DB-shaped map from db_content_to_post_map/1 (only :slug/:url_slug/ :language/:metadata), reading the cache-only fields defensively.

resolve_url_slug(group_slug, arg2, language)

Resolves URL slug to internal slug using cache/DB.

Returns:

  • {:redirect, url} for 301 redirect to new URL
  • {:ok, identifier} for resolved internal slug
  • :passthrough for direct use

resolve_url_slug_to_internal(group_slug, url_slug, language)

Resolves a URL slug to the internal post slug. Used by versioned URL handler and other places that need the internal slug.