From 2d48a4c1a7a69654b93e5eb15a27fd57c7247931 Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Mon, 14 Apr 2025 02:41:57 +0200 Subject: [PATCH] feat: Render tree without .md and everything as links --- src/Controller/MainController.php | 6 +----- templates/main/index.html.twig | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 152c7fc..0463039 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -52,8 +52,6 @@ final class MainController extends AbstractController // Convert flat list into a nested tree $tree = []; foreach ($finder as $file) { - /** @var SplFileInfo $file */ - $current = &$tree; // Dunno why it is undefined, it works @@ -66,9 +64,7 @@ final class MainController extends AbstractController $current = &$current[$part]; } - $current[] = $file; - - //usort($current, fn($a, $b) => strcmp(implode('/', $a), implode('/', $b))); + $current[$file->getFilenameWithoutExtension()] = []; } return $this->render('main/index.html.twig', [ diff --git a/templates/main/index.html.twig b/templates/main/index.html.twig index 53ee70f..f96d3b7 100644 --- a/templates/main/index.html.twig +++ b/templates/main/index.html.twig @@ -2,22 +2,18 @@ {% block title %}{{ path }} | Gaisen{% endblock %} -{% macro render_tree(tree) %} +{% macro render_tree(tree, prefix = '') %} {% endmacro %}