defmodule FirehoseWeb.Router do @moduledoc """ Example router showing how to integrate Blogex. You have two options for mounting blogs: ## Option A: Plug Router (JSON API / feeds only) Uses `Blogex.Router` directly — great for headless / API usage: scope "/blog" do pipe_through :browser forward "/engineering", Blogex.Router, blog: Firehose.EngineeringBlog forward "/releases", Blogex.Router, blog: Firehose.ReleaseNotes end ## Option B: LiveView (full UI, recommended) Uses your own LiveViews with Blogex components — full control over layout: scope "/blog", MyAppWeb do pipe_through :browser live "/engineering", BlogLive.Index, :index, metadata: %{blog: :engineering} live "/engineering/:slug", BlogLive.Show, :show, metadata: %{blog: :engineering} live "/releases", BlogLive.Index, :index, metadata: %{blog: :release_notes} live "/releases/:slug", BlogLive.Show, :show, metadata: %{blog: :release_notes} end # Still mount the Plug router for feeds scope "/blog" do forward "/engineering", Blogex.Router, blog: Firehose.EngineeringBlog forward "/releases", Blogex.Router, blog: Firehose.ReleaseNotes end ## Option C: Mixed Use LiveView for the HTML pages but let Blogex.Router handle feeds and the JSON API. Just make sure the LiveView routes are defined first so they take priority. """ use Phoenix.Router import Phoenix.LiveView.Router pipeline :browser do plug :accepts, ["html"] plug :fetch_session plug :fetch_live_flash plug :put_root_layout, html: {FirehoseWeb.Layouts, :root} plug :protect_from_forgery plug :put_secure_browser_headers end # -- Option B: LiveView routes (recommended) -- scope "/blog", MyAppWeb do pipe_through :browser # Engineering blog live "/engineering", BlogLive.Index, :index live "/engineering/tag/:tag", BlogLive.Index, :tag live "/engineering/:slug", BlogLive.Show, :show # Release notes live "/releases", BlogLive.Index, :index live "/releases/tag/:tag", BlogLive.Index, :tag live "/releases/:slug", BlogLive.Show, :show end # Feeds (served by Blogex.Router as Plug) scope "/blog" do forward "/engineering", Blogex.Router, blog: Firehose.EngineeringBlog forward "/releases", Blogex.Router, blog: Firehose.ReleaseNotes end # Sitemap scope "/" do get "/sitemap.xml", FirehoseWeb.SitemapController, :index end end