Clean-up 404 for remark->by_id

This commit is contained in:
swagg boi 2023-05-29 00:14:47 -04:00
parent f8bdcc9201
commit a220c233fa
2 changed files with 6 additions and 11 deletions

View file

@ -6,15 +6,10 @@ sub by_id($self) {
my $remark_id = $self->param('remark_id');
my $remark = $self->remark->by_id($remark_id);
if (my $remark_id = $remark->{'id'}) {
$self->stash(remark => $remark)
}
else {
$self->stash(
remark => {},
error => 'Remark not found 🤷'
)
}
$self->stash(remark => $remark);
$self->stash(error => 'Remark not found 🤷')
unless keys %{$remark};
$self->render;
}

View file

@ -1,12 +1,12 @@
% layout 'default';
% title my $remark_id = $remark->{'id'} ? "Remark #$remark_id" : '?';
<h2 class="page-title"><%= title %></h2>
<% if (my $remark_id = $remark->{'id'}) { =%>
<% if (keys %{$remark}) { =%>
<main class="pager">
<article class="post">
<h4 class="post__title">
<%= $remark->{'date'} %>
<span class="post__id">#<%= $remark_id %></span>
<span class="post__id">#<%= $remark->{'id'} %></span>
</h4>
<h5 class="post__author"><%= $remark->{'author'} %></h5>
<div class="post__body">