GamendWeb.HostLayouts (gamend_web v1.0.1215)

Copy Markdown View Source

Host-owned layout entrypoints and shared layout helpers.

Summary

Functions

Renders the application layout shell.

Shows the flash group with standard titles and content.

Encodes a schema.org object for an application/ld+json script tag.

Deep-rewrites every "href" in a theme fragment through localized_href/2.

Rewrites an internal path so it keeps the reader's locale prefix.

Provides dark vs light theme toggle based on themes defined in app.css.

Functions

app(assigns)

Renders the application layout shell.

Attributes

  • flash (:map) (required) - the map of flash messages.
  • current_scope (:map) - the current scope. Defaults to nil.
  • current_path (:string) - current request path for nav active state. Defaults to nil.
  • flush (:boolean) - when true, render content edge-to-edge with no main wrapper, padding, or footer. Defaults to false.
  • background_icons (:any) - pass false when the page paints its own decorative icon layer, as GamendWeb.PresentationPage does — otherwise the shell adds a second one on top. Defaults to nil.

Slots

  • inner_block (required)

flash_group(assigns)

Shows the flash group with standard titles and content.

Attributes

  • flash (:map) (required) - the map of flash messages.
  • id (:string) - the optional id of flash container. Defaults to "flash-group".

json_ld(object)

@spec json_ld(map()) :: String.t()

Encodes a schema.org object for an application/ld+json script tag.

nil values are dropped so callers can build objects with optional fields without emitting null, which validators flag. < is escaped because a </script> inside a string would otherwise close the tag early — the one way JSON-LD turns into an injection vector.

locale_labels()

localize_hrefs(map, locale)

@spec localize_hrefs(term(), String.t() | nil) :: term()

Deep-rewrites every "href" in a theme fragment through localized_href/2.

The nav, footer and presentation-page sections are all plain config maps, so one walk covers every configured link rather than one edit per template.

localized_href(href, locale)

@spec localized_href(term(), String.t() | nil) :: term()

Rewrites an internal path so it keeps the reader's locale prefix.

Without this the prefix survives exactly one click: /fr/about renders in French, but every link out of it points at a clean path, so the next page is back at /play — French only because the session says so. That URL is then wrong in the two places it matters, sharing it hands the recipient English, and it is the English URL that gets bookmarked and linked to.

Leaves alone: the default locale (its pages are the clean URLs), external and protocol-relative hrefs, and any path LocalePath does not serve under a prefix — pointing at /fr/blog/some-post when that only redirects would just spend a redirect per link.

root(assigns)

strip_locale_prefix(path, known_locales)

theme_toggle(assigns)

Provides dark vs light theme toggle based on themes defined in app.css.