add rel meta links for prev and next page

This commit is contained in:
r888888888
2017-10-11 15:31:13 -07:00
parent facb351552
commit d883de258c
2 changed files with 23 additions and 1 deletions

View File

@@ -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

View File

@@ -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 %>