diff --git a/src/views/components/card.ecr b/src/views/components/card.ecr index 91cde5b..0eb07a5 100644 --- a/src/views/components/card.ecr +++ b/src/views/components/card.ecr @@ -1,3 +1,13 @@ +<% if item.is_a? NamedTuple(entry: Entry, percentage: Float64, grouped_count: Int32) %> +<% grouped_count = item[:grouped_count] %> +<% if grouped_count == 1 %> +<% item = item[:entry] %> +<% else %> +<% item = item[:entry].book %> +<% end %> +<% else %> +<% grouped_count = 1 %> +<% end %>
id="<%= item.id %>" @@ -27,7 +37,11 @@

<%= item.pages %> pages

<% end %> <% if item.is_a? Title %> + <% if grouped_count == 1 %>

<%= item.size %> entries

+ <% else %> +

<%= grouped_count %> new entries

+ <% end %> <% end %>
diff --git a/src/views/home.ecr b/src/views/home.ecr index 08abe44..0b361e1 100644 --- a/src/views/home.ecr +++ b/src/views/home.ecr @@ -39,20 +39,9 @@

Continue Reading

<%- continue_reading.each do |cr| -%> -
- -
-
- -
-
-
<%= (cr[:percentage] * 100).round(1) %>%
-

"><%= cr[:entry].display_name %>

-

<%= cr[:entry].pages %> pages

-
-
-
-
+ <% item = cr[:entry] %> + <% progress = cr[:percentage] %> + <%= render_component "card" %> <%- end -%>
<%- end -%> @@ -61,36 +50,9 @@

Recently Added

<%- recently_added.each do |ra| -%> - <%- if ra[:grouped_count] == 1 -%> -
- -
-
- -
-
-
<%= (ra[:percentage] * 100).round(1) %>%
-

"><%= ra[:entry].display_name %>

-

<%= ra[:entry].pages %> pages

-
-
-
-
- <%- else -%> -
- -
-
- -
-
-

"><%= ra[:entry].book.display_name %>

-

<%= ra[:grouped_count] %> new entries

-
-
-
-
- <%- end -%> + <% item = ra %> + <% progress = ra[:percentage] %> + <%= render_component "card" %> <%- end -%>
<%- end -%>