* Add index and show pages for series
* Address code review
* Use `id` instead of `slug` to get collections
* Extract `collection_link` into the application helper
* Only count published articles
* Get rid of the `collection_link_class` method
* Add tests
* Fix test
* Use `**kwargs` instead of `options = {}`
32 lines
1.3 KiB
Text
32 lines
1.3 KiB
Text
<% collection_size = articles.size %>
|
|
<% slugs = articles.pluck(:slug) %>
|
|
|
|
<% if collection && collection_size > 1 %>
|
|
<div class="article-collection-wrapper article-collection-wrapper-<%= position %>">
|
|
<p><%= collection_link(collection) %></p>
|
|
|
|
<div class="article-collection">
|
|
<% articles.each_with_index do |article, i| %>
|
|
<% if collection_size > 5 && i == 2 %>
|
|
<a
|
|
href="<%= article.path %>"
|
|
class="<%= "current-article" if slugs[2..collection_size - 3].include?(rendered_article.slug) %> collection-link-inbetween"
|
|
data-preload-image="<%= cloud_cover_url(article.main_image) %>"
|
|
id="collection-link-inbetween"
|
|
data-no-instant
|
|
title="View more">
|
|
3 ... <%= collection_size - 2 %>
|
|
</a>
|
|
<% end %>
|
|
|
|
<a
|
|
href="<%= article.path %>"
|
|
class="<%= "current-article" if rendered_article.id == article.id %> <%= "collection-link-hidden" if collection_size > 5 && (i > 1 && i < collection_size - 2) %>"
|
|
data-preload-image="<%= cloud_cover_url(article.main_image) %>"
|
|
title="Published <%= article.readable_publish_date %>">
|
|
<%= i + 1 %>) <%= article.title %>
|
|
</a>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|