Skip to content

Commit 6e21062

Browse files
committed
Avoid generating medium representation of cover if not used in recent books
1 parent cede912 commit 6e21062

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Rules

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ preprocess do
1616

1717
@config[:favicon_reprs] = favicon_reprs
1818

19-
@config[:feed_book_identifiers] = feed_books.map(&:identifier)
19+
@config[:feed_book_isbn] = feed_books.map { |book| book[:isbn] }
20+
@config[:recent_book_isbn] = recent_books.map { |book| book[:isbn] }
2021

2122
missing_covers = 0
2223

@@ -113,9 +114,11 @@ compile '/static/**/*' do
113114
# don't filter or layout
114115
end
115116

116-
# FIXME avoid if not in recent books
117117
%i[mini medium default].each do |repr|
118118
compile '/cover/**/*', rep: repr do
119+
isbn = item.identifier.without_exts.split('/')[-1]
120+
next if repr == :medium && !@config[:recent_book_isbn].include?(isbn)
121+
119122
width = @config[:cover][:width][repr]
120123
filter :thumbnailize, width: width unless @config[:dev]
121124

@@ -125,14 +128,13 @@ end
125128
end
126129

127130
compile '/book/**/*', rep: :feed do
128-
if @config[:feed_book_identifiers].include?(item.identifier)
129-
filter :erb
130-
filter :kramdown if item[:extension] == 'md'
131-
filter :html_compressor, type: item[:extension] unless @config[:dev]
131+
next unless @config[:feed_book_isbn].include?(item[:isbn])
132+
filter :erb
133+
filter :kramdown if item[:extension] == 'md'
134+
filter :html_compressor, type: item[:extension] unless @config[:dev]
132135

133-
layout '/feed_entry.*'
134-
snapshot :feed
135-
end
136+
layout '/feed_entry.*'
137+
snapshot :feed
136138

137139
# do not write/route such representation
138140
write nil

0 commit comments

Comments
 (0)