Renders publishing post markdown to HTML with caching support.
Uses PhoenixKit.Cache for performance optimization of markdown rendering. Cache keys include content hashes for automatic invalidation.
Summary
Functions
Clears all publishing post caches.
Clears the render cache for a specific group.
Returns whether the global render cache is enabled. Checks new key first, falls back to legacy key.
Returns whether render cache is enabled for a specific group. Does not check the global setting. Checks new key first, falls back to legacy key.
Invalidates cache for a specific post.
Returns the settings key for per-group render cache. Used by other modules that need to write to the setting.
Returns whether render caching is enabled for a group.
Renders markdown or PHK content directly without caching.
Renders a post's markdown content to HTML.
Functions
Clears all publishing post caches.
Useful for testing or when doing bulk updates.
@spec clear_group_cache(String.t()) :: {:ok, non_neg_integer()} | {:error, any()}
Clears the render cache for a specific group.
Returns {:ok, count} with the number of entries cleared.
Examples
Renderer.clear_group_cache("my-group")
# => {:ok, 15}
@spec global_render_cache_enabled?() :: boolean()
Returns whether the global render cache is enabled. Checks new key first, falls back to legacy key.
Returns whether render cache is enabled for a specific group. Does not check the global setting. Checks new key first, falls back to legacy key.
Invalidates cache for a specific post.
Called when a post is updated in the admin editor.
Examples
Renderer.invalidate_cache("docs", "getting-started", "en")
Returns the settings key for per-group render cache. Used by other modules that need to write to the setting.
Returns whether render caching is enabled for a group.
Checks both the global setting and per-group setting. Both must be enabled (or default to enabled) for caching to work. Checks new keys first, falls back to legacy keys.
Renders markdown or PHK content directly without caching.
Automatically detects PHK XML format and routes to PageBuilder. Falls back to Earmark markdown rendering for non-XML content.
Examples
html = Renderer.render_markdown(content)
Renders a post's markdown content to HTML.
Caches the result for published posts using content-hash-based keys. Lazy-loads cache (only caches after first render).
Respects publishing_render_cache_enabled (global) and
publishing_render_cache_enabled_{group_slug} (per-group) settings.
Examples
{:ok, html} = Renderer.render_post(post)