HTML rendering functions for Publishing.Web.Controller.
Summary
Functions
Pre-computes date counts for timestamp-mode posts to avoid per-post DB queries.
Builds a post URL based on mode. Omits the locale prefix when the site is effectively single-language. Can also omit the default-language prefix when that setting is enabled.
Builds a public path with explicit date and time (always includes time). Used when redirecting from date-only URLs to full timestamp URLs.
Builds language data for the publishing_language_switcher component on public pages. Converts the @translations assign to the format expected by the component.
Extracts and renders an excerpt from post content. Returns content before <!-- more --> tag, or first paragraph if no tag. Renders markdown and strips HTML tags for plain text display.
Resolves a featured image URL for a post, falling back to the original variant.
Formats a date for display using locale-aware month names.
Formats a date for URL.
Formats a date with time for display. Used when multiple posts exist on the same date.
Formats a post's publication date, including time only when multiple posts exist on the same date.
Formats time for URL (HH:MM).
Builds the public URL for a group listing page. Omits the locale prefix when the site is effectively single-language. Can also omit the default-language prefix when that setting is enabled.
Checks if a post has a publication date to display. For timestamp mode, the date comes from the DB fields. For slug mode, it comes from metadata.published_at.
Pluralizes a word based on count.
Resolves the exact language-switcher code to highlight on public pages.
Functions
Pre-computes date counts for timestamp-mode posts to avoid per-post DB queries.
Returns a map of %{date_string => count} for use with build_post_url/4
and format_post_date/3.
Builds a post URL based on mode. Omits the locale prefix when the site is effectively single-language. Can also omit the default-language prefix when that setting is enabled.
For slug mode posts, uses the language-specific URL slug (from post.url_slug or post.language_slugs[language]) for SEO-friendly localized URLs.
For timestamp mode posts:
- If only one post exists on the date, uses date-only URL (e.g., /group/2025-12-09)
- If multiple posts exist on the date, includes time (e.g., /group/2025-12-09/16:26)
Builds a public path with explicit date and time (always includes time). Used when redirecting from date-only URLs to full timestamp URLs.
Builds language data for the publishing_language_switcher component on public pages. Converts the @translations assign to the format expected by the component.
Extracts and renders an excerpt from post content. Returns content before <!-- more --> tag, or first paragraph if no tag. Renders markdown and strips HTML tags for plain text display.
Resolves a featured image URL for a post, falling back to the original variant.
Formats a date for display using locale-aware month names.
Formats a date for URL.
Formats a date with time for display. Used when multiple posts exist on the same date.
Formats a post's publication date, including time only when multiple posts exist on the same date.
Formats time for URL (HH:MM).
Builds the public URL for a group listing page. Omits the locale prefix when the site is effectively single-language. Can also omit the default-language prefix when that setting is enabled.
Checks if a post has a publication date to display. For timestamp mode, the date comes from the DB fields. For slug mode, it comes from metadata.published_at.
Pluralizes a word based on count.
Resolves the exact language-switcher code to highlight on public pages.