Skip to content

Commit

Permalink
Deal with missing values for article
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-jezegou committed Dec 7, 2024
1 parent f0c6faa commit 59064c7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
Binary file added app/assets/images/landscape.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions app/components/article_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ArticleComponent < ViewComponent::Base
erb_template <<-ERB
<%= render(CardComponent.new(additional_classes: 'article')) do %>
<%= tag.div(class: 'article--images') do %>
<%= image_tag(@image_url, class: "article--main-image")%>
<%= image_tag(@image_url.presence || asset_path('landscape.jpg'), class: "article--main-image")%>
<% if @source_logo_url %>
<%= image_tag(@source_logo_url, class: "article--source-logo-image")%>
<% end %>
Expand All @@ -30,7 +30,7 @@ class ArticleComponent < ViewComponent::Base
<% end %>
<% end %>
<% end %>
<%= tag.p(@published + " - " + @source, class: "article--information") %>
<%= tag.p(@published.to_s + " - " + @source.to_s, class: "article--information") %>
<% end %>
<% end %>
<% end %>
Expand Down
2 changes: 0 additions & 2 deletions app/components/layout_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ def articles
},
{
title: "Changements climatiques: le futur de la planète en jeu",
image_url: "https://via.placeholder.com/375",
published: "2j",
source: "Le Monde",
source_logo_url: "https://via.placeholder.com/100",
tags: [{ text: "Climate", path: "/tags/3" }, { text: "Environment", path: "/tags/4" }],
content: "Les experts alertent sur les conséquences graves du réchauffement climatique, mettant en lumière les défis pour les décennies à venir."
}
Expand Down

0 comments on commit 59064c7

Please sign in to comment.