Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
syedbarimanjan committed May 1, 2024
1 parent c6ea217 commit 2ab7993
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def index

def show
@article = Article.where(slug: params[:id]).first
@next_articles = Article.where("id > ?", @article.id).limit(3)
@next_articles = Article.where.not(slug: @article.slug).limit(3)

if @article.nil?
redirect_to '/404'

Check failure on line 11 in app/controllers/articles_controller.rb

View workflow job for this annotation

GitHub Actions / lint

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Expand Down
6 changes: 2 additions & 4 deletions app/views/articles/_article_card.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<%# locals: (article:) -%>
<div class="overflow-hidden rounded-2xl shadow transition hover:shadow-lg p-1 bg-white">
<a href="<%= article_url(article.slug) %>" class="flex flex-col justify-between h-full gap-5">
<%= link_to article_url(article.slug), class: "overflow-hidden rounded-xl shadow transition hover:shadow-lg p-1 bg-white border flex flex-col justify-between h-full gap-5" do %>
<div class="h-56 w-full object-cover bg-gradient-to-b <%= article_random_gradient(article) %> rounded-xl"></div>
<div class="flex flex-col flex-grow justify-between">
<div class="flex items-center gap-3 px-6">
Expand All @@ -16,5 +15,4 @@
<p><%= article.author_name %></p>
</div>
</div>
</a>
</div>
<% end %>
6 changes: 3 additions & 3 deletions app/views/articles/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div class="max-w-5xl mx-auto text-center">
<div class="flex flex-col gap-y-1">
<div class="flex items-center justify-center gap-x-2">
<h1 class="text-3xl font-medium tracking-tight">Maybe Articles</h1>
<%= image_tag("icon-articles.svg", alt: "Articles", class: "inline") %>
<h1 class="text-3xl font-medium tracking-tight">Maybe Blog</h1>
<%= image_tag("icon-articles.svg", alt: "Blog", class: "inline") %>
</div>
<p class="text-sm text-neutral-400">Thoughts and insights around personal finance.</p>
</div>
<div class="grid grid-cols-3 gap-4 mt-7 mb-14">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-4 mt-7 mb-14">
<% @articles.each do |article| %>
<%= render partial: "articles/article_card", locals: { article: article } %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/articles/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</div>
</div>
</article>
<div class="grid grid-cols-3 gap-4 mt-7 mb-14">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-4 mt-7 mb-14">
<% @next_articles.each do |next_article| %>
<%= render "articles/article_card", article: next_article %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<span class="px-1.5 py-0.5 text-[0.1em] uppercase bg-white border rounded-full border-neutral-200/75 text-neutral-500">Early Access</span>
</div>
<nav class="flex-1 text-sm text-center gap-x-1">
<%= link_to "Articles", articles_path, class: "px-3 py-1.5 text-neutral-800 hover:text-neutral-900 hover:bg-neutral-200/60 rounded-xl" %>
<%= link_to "Blog", articles_path, class: "px-3 py-1.5 text-neutral-800 hover:text-neutral-900 hover:bg-neutral-200/60 rounded-xl" %>
<a href="#" class="px-3 py-1.5 text-neutral-800 hover:text-neutral-900 hover:bg-neutral-200/60 rounded-xl">Glossary</a>
<a href="https://github.com/maybe-finance/maybe" class="px-3 py-1.5 text-neutral-800 hover:text-neutral-9000 hover:bg-neutral-200/60 rounded-xl">Contribute</a>
</nav>
Expand All @@ -53,7 +53,7 @@
<h4 class="mb-4 text-xs font-medium uppercase">General</h4>
<ul>
<li>
<%= link_to "Articles", articles_path %>
<%= link_to "Blog", articles_path %>
</li>
<li>
<%= link_to "Glossary", "#" %>
Expand Down

0 comments on commit 2ab7993

Please sign in to comment.