支持前后博文的跳转
This commit is contained in:
parent
261ce3bfec
commit
69b90ae5fd
|
@ -23,6 +23,13 @@
|
||||||
|
|
||||||
.next {
|
.next {
|
||||||
float: right;
|
float: right;
|
||||||
|
i {
|
||||||
|
margin-left: 0.275rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.prev i {
|
||||||
|
margin-right: 0.275rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
.markdown {
|
.markdown {
|
||||||
|
|
||||||
|
word-wrap: break-word;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
@media only screen and (min-width: 40.063em) {
|
@media only screen and (min-width: 40.063em) {
|
||||||
h1, h2, h3, h4, h5, h6 {
|
h1, h2, h3, h4, h5, h6 {
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
|
|
|
@ -13,7 +13,9 @@ class BlogsController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@post = Post.find(params[:id])
|
@post = Post.find(params[:id])
|
||||||
@comments = Comment.all.where(post_id: @post.id)
|
@prev = Post.where(:created_at.lt => @post.created_at).desc(:created_at).where(:id.ne => @post.id).first
|
||||||
|
@next = Post.where(:created_at.gt => @post.created_at).asc(:created_at).where(:id.ne => @post.id).first
|
||||||
|
@comments = @post.comments
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -7,7 +7,11 @@
|
||||||
= render partial: 'comment', locals: { comments: @comments }
|
= render partial: 'comment', locals: { comments: @comments }
|
||||||
.row
|
.row
|
||||||
.small-12.large-8.columns
|
.small-12.large-8.columns
|
||||||
a.prev href="#"
|
- if @prev
|
||||||
span.has-tip data-tooltip="" title="hello" Prev
|
= link_to blog_path(@prev), class: 'prev' do
|
||||||
a.next href="#"
|
i.fi-arrow-left
|
||||||
span.has-tip data-tooltip="" title="hello" Next
|
| Prev
|
||||||
|
- if @next
|
||||||
|
= link_to blog_path(@next), class: 'next' do
|
||||||
|
| Next
|
||||||
|
i.fi-arrow-right
|
||||||
|
|
Loading…
Reference in New Issue