diff --git a/content/blog/feed.erb b/content/blog/feed.erb index 0f128a71..439a9500 100644 --- a/content/blog/feed.erb +++ b/content/blog/feed.erb @@ -5,7 +5,7 @@ is_hidden_from_human_search: true author_name: @config[:blog][:author_name], author_uri: @config[:blog][:author_uri], articles: published_blog_posts, - content_proc: ->(post) { prepare_item_for_feed(post) }, - excerpt_proc: ->(post) { prepare_item_for_feed(post, summary: true) }, + content_proc: ->(post) { post.compiled_content(rep: :feed_entry) }, + excerpt_proc: ->(post) { post_summary(post.reps.fetch(:feed_entry)) }, limit: 10 %> diff --git a/lib/helpers/blogging.rb b/lib/helpers/blogging.rb index 225edb13..92841823 100644 --- a/lib/helpers/blogging.rb +++ b/lib/helpers/blogging.rb @@ -92,11 +92,20 @@ def archive_years(posts = nil) years.to_a end - def post_summary(post, read_more_text: "Read more ⇢", separator: "") - summary, body = post.compiled_content.split(separator) + def post_summary(post_rep, read_more_text: "Read more ⇢", separator: "") + post_rep = case post_rep + when Nanoc::ItemRepView + post_rep + when Nanoc::ItemWithRepsView + post_rep.reps.fetch(:default) + else + raise ArgumentError, "Cannot summarize #{item_rep.inspect} (expected an item rep or an item, not a #{item_rep.class.name})" + end + + summary, body = post_rep.compiled_content.split(separator) return summary unless body - link = link_to(post.fetch(:read_more, read_more_text), post, class: "readmore", title: "Read the full article") + link = link_to(post_rep.item.fetch(:read_more, read_more_text), post_rep.item, global: post_rep.name != :default, class: "readmore", title: "Read the full article") summary << %[

#{link}

] end diff --git a/rules/blog.rb b/rules/blog.rb index e65b70bd..27eaa790 100644 --- a/rules/blog.rb +++ b/rules/blog.rb @@ -38,3 +38,12 @@ filter :cache_buster if @config[:production] filter :html5small if @config[:production] end + +compile '/static/blog/**/*.md', rep: :feed_entry do + filter :erb, @config[:erb] + filter :kramdown, @config[:kramdown] + filter :colorize_syntax, + default_colorizer: :rouge + filter :absolutify_paths, type: :html, global: true + filter :rubypantsunicode +end