blog nav, prev and next, some tweaking
This commit is contained in:
@ -1,10 +1,9 @@
|
||||
module ApplicationHelper
|
||||
def post_link(index)
|
||||
post = Post.posts.values[index]
|
||||
def post_link(post)
|
||||
return "" unless post
|
||||
link = post.date.to_s + " "
|
||||
link += link_to( post.title , blog_post_url(post.slug))
|
||||
link.html_safe
|
||||
link_to(blog_post_url(post.slug)) do
|
||||
"#{post.title.capitalize} <span>(#{post.date})</span>".html_safe
|
||||
end.html_safe
|
||||
end
|
||||
|
||||
def ext_link(name = nil, options = nil, html_options = nil, &block)
|
||||
@ -22,4 +21,19 @@ module ApplicationHelper
|
||||
def title(title)
|
||||
@title = title
|
||||
end
|
||||
|
||||
def prev_post(post)
|
||||
index = Post.posts.keys.index(post.slug)
|
||||
nav_post(index + 1 , "prev")
|
||||
end
|
||||
def next_post(post)
|
||||
index = Post.posts.keys.index(post.slug)
|
||||
nav_post(index - 1 , "next")
|
||||
end
|
||||
def nav_post(index, dir)
|
||||
return "" unless index >= 0
|
||||
post = Post.posts.values[index]
|
||||
return "" unless post
|
||||
link_to("#{dir} <span>(#{post.date})</span>".html_safe , blog_post_url(post.slug) , alt: post.title.capitalize)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user