From 5ae258317decdfdfb793e23ab3a405f57eed9841 Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Mon, 14 Apr 2025 02:45:20 +0200 Subject: [PATCH] feat: Don't explode on non-existent files --- src/Controller/MainController.php | 3 +-- templates/main/index.html.twig | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 0463039..1e6e75a 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -38,8 +38,7 @@ final class MainController extends AbstractController ); $fs = new Filesystem(); - if (!$fs->exists($fullPath)) throw $this->createNotFoundException(); - $contents = $fs->readFile($fullPath); + $contents = $fs->exists($fullPath) ? $fs->readFile($fullPath) : null; // -------------------------------------------------- Get data tree --- diff --git a/templates/main/index.html.twig b/templates/main/index.html.twig index f96d3b7..7632d10 100644 --- a/templates/main/index.html.twig +++ b/templates/main/index.html.twig @@ -26,7 +26,11 @@ {{ _self.render_tree(tree) }}
+ {% if contents is not null %} {{ contents|markdown_to_html }} + {% else %} + Empty + {% endif %}