PhoenixKit.Modules.Publishing.DBStorage.Mapper (phoenix_kit v1.7.71)

Copy Markdown View Source

Mapper: converts DB records to the map format expected by Publishing's web layer (LiveViews, templates, controllers).

Map Shape

The web layer expects maps with these keys:

  • :group - group slug
  • :slug - post directory slug
  • :url_slug - per-language URL slug
  • :date - Date struct (timestamp mode)
  • :time - Time struct (timestamp mode)
  • :mode - :timestamp or :slug atom
  • :language - current language code
  • :available_languages - list of language codes
  • :language_statuses - %{language => status}
  • :version - current version number
  • :available_versions - list of version numbers
  • :version_statuses - %{version_number => status}
  • :version_dates - %{version_number => date_string}
  • :content - markdown/PHK body
  • :metadata - map with :title, :description, :status, :slug, etc.
  • :primary_language - primary language code

Summary

Functions

Converts a full post read (post + version + content + all contents + all versions) into the legacy map format expected by the web layer.

Converts a post to a listing-format map (no content body, just metadata). Used for listing pages where full content isn't needed.

Functions

to_legacy_map(post, version, content, all_contents, all_versions, opts \\ [])

Converts a full post read (post + version + content + all contents + all versions) into the legacy map format expected by the web layer.

to_listing_map(post, version, all_contents, all_versions, opts \\ [])

Converts a post to a listing-format map (no content body, just metadata). Used for listing pages where full content isn't needed.