streamline the feed controller with put_root_layout plug, write post about it
This commit is contained in:
parent
9291bdb88c
commit
662e85da6c
4 changed files with 37 additions and 12 deletions
lib/home73k_web
|
@ -1,5 +1,7 @@
|
|||
defmodule Home73kWeb.FeedController do
|
||||
use Home73kWeb, :controller
|
||||
plug :put_layout, false
|
||||
plug :put_root_layout, false
|
||||
|
||||
alias Home73k.Blog
|
||||
|
||||
|
@ -9,7 +11,6 @@ defmodule Home73kWeb.FeedController do
|
|||
|
||||
conn
|
||||
|> put_resp_content_type("application/rss+xml")
|
||||
|> put_layout(:false)
|
||||
|> render("rss.xml", posts: posts, last_build_date: last_build_date)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
</div>
|
||||
|
||||
<%= if length(post.tags) > 0 do %>
|
||||
<div class="post-tags fs-smaller mb-3">
|
||||
<div class="post-tags fs-smaller mb-4">
|
||||
<%= icon_div @socket, "mdi-tag-multiple", [class: "icon baseline text-gray-300"] %>
|
||||
<%= for {tag, i} <- Enum.with_index(post.tags) do %>
|
||||
<span class="text-gray-300">#</span><%= live_redirect tag, to: Routes.blog_path(@socket, :tag, tag) %><%= i < (length(post.tags) - 1) && "," || "" %>
|
||||
|
|
|
@ -3,7 +3,7 @@ defmodule Home73kWeb.Router do
|
|||
alias Home73kWeb.CSPHeader
|
||||
|
||||
pipeline :browser do
|
||||
plug :accepts, ["html"]
|
||||
plug :accepts, ~w(html xml)
|
||||
plug :fetch_session
|
||||
plug :fetch_live_flash
|
||||
plug :put_root_layout, {Home73kWeb.LayoutView, :root}
|
||||
|
@ -12,10 +12,6 @@ defmodule Home73kWeb.Router do
|
|||
plug CSPHeader
|
||||
end
|
||||
|
||||
pipeline :xml_rss do
|
||||
plug :accepts, ["xml", "rss", "atom"]
|
||||
end
|
||||
|
||||
pipeline :api do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
@ -36,13 +32,9 @@ defmodule Home73kWeb.Router do
|
|||
live "/blog/page/:page", BlogLive, :page
|
||||
live "/blog/tag/:tag", BlogLive, :tag
|
||||
live "/blog/:id", BlogLive, :show
|
||||
end
|
||||
|
||||
scope "/feed", Home73kWeb do
|
||||
pipe_through :xml_rss
|
||||
|
||||
# Feeds
|
||||
get "/", FeedController, :rss
|
||||
get "/feed", FeedController, :rss
|
||||
end
|
||||
|
||||
# Other scopes may use custom stacks.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue