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