diff --git a/apps/content/lib/content/sitemap.ex b/apps/content/lib/content/sitemap.ex index 4705b550..e2eeda00 100644 --- a/apps/content/lib/content/sitemap.ex +++ b/apps/content/lib/content/sitemap.ex @@ -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 diff --git a/apps/content/lib/content_web/controllers/posts_controller.ex b/apps/content/lib/content_web/controllers/posts_controller.ex index c5b19b33..a1eb7444 100644 --- a/apps/content/lib/content_web/controllers/posts_controller.ex +++ b/apps/content/lib/content_web/controllers/posts_controller.ex @@ -58,7 +58,7 @@ defmodule Legendary.Content.PostsController do conn |> index_posts(%{"id" => "blog", "page" => page_string}) end - def show(conn, %{"id" => id, "page" => page_string}) do + def show(conn, %{"id" => id, "page" => page_string}) when is_binary(id) or is_integer(id) do post = Posts.get_post(id) if is_nil(post) do @@ -67,6 +67,9 @@ defmodule Legendary.Content.PostsController do conn |> show_one(post, page_string) end end + def show(conn, %{"id" => id, "page" => page_string}) when is_list(id) do + show(conn, %{"id" => Enum.join(id, "/"), "page" => page_string}) + end def show(conn, %{"id" => id}), do: show(conn, %{"id" => id, "page" => "1"}) defp try_static_post(conn, id) do diff --git a/apps/content/lib/content_web/routes.ex b/apps/content/lib/content_web/routes.ex index 9380c07d..a4b3244b 100644 --- a/apps/content/lib/content_web/routes.ex +++ b/apps/content/lib/content_web/routes.ex @@ -33,7 +33,7 @@ defmodule Legendary.Content.Routes do get "/", PostsController, :index resources "/sitemap", SitemapController, only: [:index] get "/:id", PostsController, :show - get "/:id/:page", PostsController, :show, as: :paged_post + get "/*id", PostsController, :show, as: :nested_posts end end end diff --git a/apps/content/lib/content_web/templates/posts/pagination.html.eex b/apps/content/lib/content_web/templates/posts/pagination.html.eex index f6a553ed..4b26928b 100644 --- a/apps/content/lib/content_web/templates/posts/pagination.html.eex +++ b/apps/content/lib/content_web/templates/posts/pagination.html.eex @@ -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 diff --git a/apps/content/test/content_web/controllers/posts_controller_test.exs b/apps/content/test/content_web/controllers/posts_controller_test.exs index f0a9d9c7..6a220703 100644 --- a/apps/content/test/content_web/controllers/posts_controller_test.exs +++ b/apps/content/test/content_web/controllers/posts_controller_test.exs @@ -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