View Source Upgrading to v0.3.0

Move Beacon after the endpoint in application.ex

Beacon needs to access each site's endpoint info in order to boot the sites, so those endpoints must be started before the Beacon supervisor.

Open the file application.ex, find the Beacon tuple in the list of children, and move it to after the endpoint(s) declarations, usually at the end of that list:

@impl true
def start(_type, _args) do
  children = [
    # ...
    MyAppWeb.Endpoint,
    {Beacon, [sites: [Application.fetch_env!(:beacon, :my_site)]]} # <- moved to after `MyAppWeb.Endpoint`
  ]

Add Beacon.Plug to your Router

In your application's router.ex file, first find where your sites are defined:

scope "/", MyAppWeb do
  pipe_through :browser
  beacon_site "/", site: :my_site
end

In the above case we can see the site :my_site is inside a scope piped through :browser, so let's add a new :beacon pipeline with the Beacon.Plug:

pipeline :beacon do
  plug Beacon.Plug
end

And add that pipeline into the existing scope:

scope "/", MyAppWeb do
  pipe_through [:browser, :beacon] # <- add the pipeline here
  beacon_site "/", site: :my_site
end

Now the Beacon.Plug will ensure consistent rendering, particularly important when Page Variants are used.