feat: Don't explode on non-existent files

This commit is contained in:
Dendy 2025-04-14 02:45:20 +02:00
parent 2d48a4c1a7
commit 5ae258317d
2 changed files with 5 additions and 2 deletions

View File

@ -38,8 +38,7 @@ final class MainController extends AbstractController
); );
$fs = new Filesystem(); $fs = new Filesystem();
if (!$fs->exists($fullPath)) throw $this->createNotFoundException(); $contents = $fs->exists($fullPath) ? $fs->readFile($fullPath) : null;
$contents = $fs->readFile($fullPath);
// -------------------------------------------------- Get data tree --- // -------------------------------------------------- Get data tree ---

View File

@ -26,7 +26,11 @@
{{ _self.render_tree(tree) }} {{ _self.render_tree(tree) }}
</div> </div>
<div class="p-3"> <div class="p-3">
{% if contents is not null %}
{{ contents|markdown_to_html }} {{ contents|markdown_to_html }}
{% else %}
<span class="text-muted">Empty</span>
{% endif %}
</div> </div>
</div> </div>
<div class="bg-neutral-3 border-top w-100 p-2"> <div class="bg-neutral-3 border-top w-100 p-2">