From c197f092ac73a0309aee95b8711737ac0cc84981 Mon Sep 17 00:00:00 2001 From: programarivm Date: Fri, 3 May 2024 20:05:33 +0200 Subject: [PATCH] Hello world --- composer.json | 4 +++- config/routes.yaml | 10 ++++++++++ posts/hello-world.md | 3 +++ src/Controller/PostController.php | 22 ++++++++++++++++++++++ templates/post.html.twig | 25 +++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 posts/hello-world.md create mode 100644 src/Controller/PostController.php create mode 100644 templates/post.html.twig diff --git a/composer.json b/composer.json index 8c982f7c..0c1481b8 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "php": ">=8.2", "ext-ctype": "*", "ext-iconv": "*", + "league/commonmark": "^2.4", "symfony/asset": "7.0.*", "symfony/asset-mapper": "7.0.*", "symfony/console": "7.0.*", @@ -17,7 +18,8 @@ "symfony/translation": "7.0.*", "symfony/twig-bundle": "7.0.*", "symfony/yaml": "7.0.*", - "twig/extra-bundle": "^2.12|^3.0", + "twig/extra-bundle": "^3.9", + "twig/markdown-extra": "^3.9", "twig/twig": "^2.12|^3.0" }, "require-dev": { diff --git a/config/routes.yaml b/config/routes.yaml index 951fc109..442ee310 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -162,3 +162,13 @@ sitemap: path: /sitemap.xml controller: App\Controller\SitemapController::index methods: GET + +post_hello_world: + path: /{_locale}/hello-world + controller: App\Controller\PostController::hello_world + methods: GET + requirements: + _locale: en|es|fr + options: + sitemap: + _locale: en diff --git a/posts/hello-world.md b/posts/hello-world.md new file mode 100644 index 00000000..001613f2 --- /dev/null +++ b/posts/hello-world.md @@ -0,0 +1,3 @@ +# Hello world! + +How are things going? diff --git a/src/Controller/PostController.php b/src/Controller/PostController.php new file mode 100644 index 00000000..ed7b21e4 --- /dev/null +++ b/src/Controller/PostController.php @@ -0,0 +1,22 @@ +render('post.html.twig', [ + 'title' => 'Hello World!', + 'description' => 'This is my first post.', + 'content' => $content, + ]); + } +} diff --git a/templates/post.html.twig b/templates/post.html.twig new file mode 100644 index 00000000..d7b39fbf --- /dev/null +++ b/templates/post.html.twig @@ -0,0 +1,25 @@ + + + + + + + {{ title }} + + + + + + + + {% include 'partial/nav.html.twig' %} +
+
+ {% apply markdown_to_html %} + {{ content | raw }} + {% endapply %} +
+
+ {% include 'partial/footer.html.twig' %} + +