PhoenixKit.Modules.Publishing.Web.Controller.Listing (phoenix_kit v1.7.33)

Copy Markdown View Source

Blog listing functionality for the publishing controller.

Handles rendering blog post listings with:

  • Language filtering and fallback
  • Pagination
  • Translation link building for listings

Summary

Functions

Gets the default blog listing path for a language.

Fetches blog configuration by slug.

Filter posts to only include those that have a matching language file. Handles both exact matches and base code matches (e.g., "en" matches "en-US"). Uses preloaded language_statuses to avoid redundant file reads.

Strict version - only matches exact language, no fallback to base code.

Filters posts to only include published ones.

Find a matching language in available languages. Handles exact matches and base code matching.

Get the actual language that the fallback matched. Used to redirect to the correct URL when requested language has no content.

Gets the page number from params.

Gets the posts per page setting.

Paginates a list of posts.

Renders the blog index page with resolved posts.

Resolves posts for the requested language, handling exact match vs fallback.

Functions

default_blog_listing(language)

Gets the default blog listing path for a language.

fetch_blog(blog_slug)

Fetches blog configuration by slug.

filter_by_exact_language(posts, blog_slug, language)

Filter posts to only include those that have a matching language file. Handles both exact matches and base code matches (e.g., "en" matches "en-US"). Uses preloaded language_statuses to avoid redundant file reads.

filter_by_exact_language_strict(posts, language)

Strict version - only matches exact language, no fallback to base code.

filter_published(posts)

Filters posts to only include published ones.

find_matching_language(language, available_languages)

Find a matching language in available languages. Handles exact matches and base code matching.

get_fallback_language(requested_language, posts)

Get the actual language that the fallback matched. Used to redirect to the correct URL when requested language has no content.

get_page_param(params)

Gets the page number from params.

get_per_page_setting()

Gets the posts per page setting.

paginate(posts, page, per_page)

Paginates a list of posts.

render_blog_index(conn, ctx, all_posts)

Renders the blog index page with resolved posts.

render_blog_listing(conn, blog_slug, language, params)

Renders a blog listing page.

resolve_listing_posts_for_language(conn, ctx)

Resolves posts for the requested language, handling exact match vs fallback.