Last active
December 11, 2015 12:38
-
-
Save komasaru/4601648 to your computer and use it in GitHub Desktop.
Ruby script to generate pager for each article.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Previous(Older) article | |
def prev_link | |
prv = sorted_articles.index(@item) + 1 | |
unless articles.size - 1 < prv | |
link_to( | |
'«[Older] ' + sorted_articles[prv][:title], | |
sorted_articles[prv].reps[0], | |
:class => "prev" | |
) | |
end | |
end | |
# Next(Newer) article | |
def next_link | |
nxt = sorted_articles.index(@item) - 1 | |
unless nxt < 0 | |
link_to( | |
sorted_articles[nxt][:title] + ' [Newer]»', | |
sorted_articles[nxt].reps[0], | |
:class => "next" | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment