Created
July 18, 2012 07:21
Revisions
-
1gor revised this gist
Jul 18, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ module Helpers def article_summary(item, read_more_text="Read more...", separator="<!--MORE-->") summary,body = item.compiled_content.split(separator) return item.compiled_content unless body link = link_to( (item[:read_more] || read_more_text), item.path, :class=>'readmore' ) return summary+"<p class='readmore'>#{link}</p>" end end -
1gor created this gist
Jul 18, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ module My module Helpers # Nanoc helper to display blog post summary and a link to the full post. # Used inside <% sorted_articles.each do |item| %>...<% end %> block etc. # # @example Put the following in your layout: # # <%= article_summary(item,'Read the full article>>') %> # # To customize the link text you can add 'read_more' attribute to your # item metadata or pass the string to the helper, as above. # # Add <!--MORE--> separator somewhere in your item to split it. Otherwise # the full article text is displayed. # # @param [String] item The blog post # # @param [String] read_more_text The 'Read more...' text # # @param [String] separator Separates item summary from item body. Defaults to <!--MORE--> # def article_summary(item, read_more_text="Read more...", separator="<!--MORE-->") summary,body = item.compiled_content.split(separator) return item.compiled_content unless body link = link_to( (item[:read_more] || read_more_text), item.path, :class=>'read_more' ) return summary+"<p class='readmore'>#{link}</p>" end end end