From 5820652ac1c34bd33b290655cce9313f58063936 Mon Sep 17 00:00:00 2001 From: Akshit Garg Date: Wed, 16 Feb 2022 16:30:30 +0530 Subject: [PATCH] feat: add support for custom page titles Also put the paste ID in the title for the show page --- lib/ketbin_web/controllers/page_controller.ex | 3 ++- lib/ketbin_web/templates/layout/app.html.heex | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ketbin_web/controllers/page_controller.ex b/lib/ketbin_web/controllers/page_controller.ex index 08c8485..d3d6d76 100644 --- a/lib/ketbin_web/controllers/page_controller.ex +++ b/lib/ketbin_web/controllers/page_controller.ex @@ -28,7 +28,8 @@ defmodule KetbinWeb.PageController do render(conn, "show.html", paste: paste, show_edit: show_edit, - extension: List.first(tail) || "" + extension: List.first(tail) || "", + page_title: paste.id ) end end diff --git a/lib/ketbin_web/templates/layout/app.html.heex b/lib/ketbin_web/templates/layout/app.html.heex index f9aacb8..3efa2b5 100644 --- a/lib/ketbin_web/templates/layout/app.html.heex +++ b/lib/ketbin_web/templates/layout/app.html.heex @@ -4,7 +4,11 @@ - Katbin + <%= if Map.has_key?(assigns, :page_title) do %> + Katbin - <%= @page_title %> + <% else %> + Katbin + <% end %>