mix phoenix_page_meta.install (PhoenixPageMeta v0.2.0)

Copy Markdown View Source

Sets up phoenix_page_meta in the Phoenix project

Performs four steps:

  1. Adds a config :phoenix_page_meta block to config/config.exs with starter values (:site_name, :supported_locales, :extra_fields). The prebuilt PhoenixPageMeta.PageMeta struct is config-driven — there is no per-app PageMeta module to create.

  2. Injects <PhoenixPageMeta.Components.MetaTags.default> into lib/<app_web>/components/layouts/root.html.heex, right before the existing <.live_title element.

  3. Adds @behaviour PhoenixPageMeta.LiveView and import PhoenixPageMeta.LiveView, only: [assign_page_meta: 1] after use Phoenix.LiveView inside the def live_view macro in the main web module.

  4. Adds alias PhoenixPageMeta.PageMeta inside the defp html_helpers block in the main web module so that templates and LiveViews can reference %PageMeta{} directly.

All four steps are idempotent — re-running the task is safe.

Example

mix phoenix_page_meta.install