Merge branch 'master' of gitlab.com:mythic-insight/legendary

This commit is contained in:
Robert Prehn 2021-03-25 17:49:09 -05:00
commit a8b4dd2dca
5 changed files with 6 additions and 6 deletions

View file

@ -36,7 +36,7 @@ defmodule Legendary.Content.Sitemaps do
if page_count > 1 do
(2..page_count)
|> Enum.each(fn page ->
add Helpers.paged_post_path(Endpoint, :show, post, page), priority: 0.5, changefreq: "hourly", expires: nil
add Helpers.posts_path(Endpoint, :show, post, page: page), priority: 0.5, changefreq: "hourly", expires: nil
end)
end
end

View file

@ -68,7 +68,7 @@ defmodule Legendary.Content.PostsController do
end
end
def show(conn, %{"id" => id, "page" => page_string}) when is_list(id) do
show(conn, %{"id" => Enum.join(id, "/"), "page" => "1"})
show(conn, %{"id" => Enum.join(id, "/"), "page" => page_string})
end
def show(conn, %{"id" => id}), do: show(conn, %{"id" => id, "page" => "1"})

View file

@ -32,8 +32,8 @@ defmodule Legendary.Content.Routes do
post "/wp-login.php", PostPasswordController, :create
get "/", PostsController, :index
resources "/sitemap", SitemapController, only: [:index]
get "/*id", PostsController, :show
get "/:id/:page", PostsController, :show, as: :paged_post
get "/:id", PostsController, :show
get "/*id", PostsController, :show, as: :nested_posts
end
end
end

View file

@ -5,7 +5,7 @@
1..Legendary.Content.Post.content_page_count(@post),
fn page ->
if assigns[:current_page] == nil || assigns[:current_page] != page do
link page, to: Routes.paged_post_path(@conn, :show, @post, page)
link page, to: Routes.posts_path(@conn, :show, @post, page: page)
else
content_tag :span, page, class: "paginator-page"
end

View file

@ -154,7 +154,7 @@ defmodule Legendary.Content.PostsControllerTest do
end
test "shows the post with pagination", %{conn: conn, posts: posts} do
conn = get conn, Routes.paged_post_path(conn, :show, posts, "2")
conn = get conn, Routes.posts_path(conn, :show, posts, page: "2")
assert html_response(conn, 200) =~ posts.title
end