„lib/chiya_web/controllers/page_controller.ex“ ändern

This commit is contained in:
inhji 2023-03-17 09:44:46 +01:00
parent 0c567f3689
commit 401edc3f9b

View file

@ -2,19 +2,14 @@ defmodule ChiyaWeb.PageController do
use ChiyaWeb, :controller use ChiyaWeb, :controller
def home(conn, _params) do def home(conn, _params) do
# The home page is often custom made,
# so skip the default app layout.
settings = conn.assigns.settings settings = conn.assigns.settings
channel = channel = case settings.home_channel_id do
if settings.home_channel_id != nil do nil -> nil
Chiya.Channels.get_channel!(settings.home_channel_id) id -> Chiya.Channels.get_channel!(id) |> Chiya.Channels.preload_channel_public()
|> Chiya.Channels.preload_channel_public()
else
nil
end end
render(conn, :home, layout: {ChiyaWeb.Layouts, "public.html"}, channel: channel) render(conn, :home, layout: {ChiyaWeb.Layouts, "public.html"}, channel: channel, page_title: "Home")
end end
def channel(conn, %{"slug" => channel_slug}) do def channel(conn, %{"slug" => channel_slug}) do
@ -22,7 +17,7 @@ defmodule ChiyaWeb.PageController do
Chiya.Channels.get_channel_by_slug!(channel_slug) Chiya.Channels.get_channel_by_slug!(channel_slug)
|> Chiya.Channels.preload_channel_public() |> Chiya.Channels.preload_channel_public()
render(conn, :channel, layout: {ChiyaWeb.Layouts, "public.html"}, channel: channel) render(conn, :channel, layout: {ChiyaWeb.Layouts, "public.html"}, channel: channel, page_title: channel.name)
end end
def note(conn, %{"slug" => note_slug}) do def note(conn, %{"slug" => note_slug}) do
@ -31,7 +26,7 @@ defmodule ChiyaWeb.PageController do
if is_nil(note.published_at) do if is_nil(note.published_at) do
render_error(conn, :not_found) render_error(conn, :not_found)
else else
render(conn, :note, layout: {ChiyaWeb.Layouts, "public.html"}, note: note) render(conn, :note, layout: {ChiyaWeb.Layouts, "public.html"}, note: note, page_title: note.name)
end end
end end
end end