Verified Commit 51f45081 authored by Diane's avatar Diane

Fixed error on unpublished article viewing

parent 0e967969
......@@ -10,7 +10,6 @@ use App\Helpers\DateHelper;
use App\Services\Renderers;
use App\Services\Repositories;
use App\Types\RenderMode;
use function Siler\Http\Response\html;
/**
* Class Show
......@@ -57,8 +56,10 @@ class Show implements Action
}
// ViewModel preparation
$article['rendered_date'] = DateHelper::fromStoredDate($article['publication_date'])
->asFullDate();
$article['rendered_date'] = !is_null($article['publication_date'])
? DateHelper::fromStoredDate($article['publication_date'])
->asFullDate()
: 'unpublished';
$article['has_category'] = CategoryHelper::hasCategory($article);
$this->renderer->render($mode, $article);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment