Permalink
Browse files

add rel meta links for prev and next page

  • Loading branch information...
r888888888 committed Oct 11, 2017
1 parent facb351 commit d883de258c624d15ea488319f7c4783c401244e7
Showing with 23 additions and 1 deletion.
  1. +18 −0 app/helpers/posts_helper.rb
  2. +5 −1 app/views/posts/index.html.erb
@@ -1,4 +1,22 @@
module PostsHelper
def next_page_url
current_page = (params[:page] || 1).to_i
dup_params = params.dup
dup_params[:page] = current_page + 1
url_for(dup_params).html_safe
end
def prev_page_url
current_page = (params[:page] || 1).to_i
if current_page >= 2
dup_params = params.dup
dup_params[:page] = current_page - 1
url_for(dup_params).html_safe
else
nil
end
end
def missed_post_search_count_js
return nil unless Danbooru.config.enable_post_search_counts
@@ -63,7 +63,11 @@
<%= content_for(:html_header) do %>
<link href="<%= posts_path(:format => 'atom', :tags => params[:tags]) %>" rel="alternate" title="ATOM" type="application/atom+xml" />
<%= content_tag(:link, nil, rel: "prefetch", href: posts_path(tags: params[:tags], page: (params[:page] || 1).to_i + 1), as: "html", crossorigin: "use-credentials") %>
<%= content_tag(:link, nil, rel: "prefetch", href: next_page_url, as: "html", crossorigin: "use-credentials") %>
<%= content_tag :link, nil, rel: "next", href: next_page_url %>
<% if prev_page_url %>
<%= content_tag :link, nil, rel: "prev", href: prev_page_url %>
<% end %>
<% if @post_set.has_wiki? %>
<meta name="description" content="<%= @post_set.wiki_page.presenter.blurb %>">
<% else %>

0 comments on commit d883de2

Please sign in to comment.