Skip to content

Commit

Permalink
Hello world
Browse files Browse the repository at this point in the history
  • Loading branch information
programarivm committed May 3, 2024
1 parent ea3133c commit c197f09
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.*",
Expand All @@ -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": {
Expand Down
10 changes: 10 additions & 0 deletions config/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions posts/hello-world.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Hello world!

How are things going?
22 changes: 22 additions & 0 deletions src/Controller/PostController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;

class PostController extends AbstractController
{
const DATA_FOLDER = __DIR__ . '/../../posts';

public function hello_world(): Response
{
$content = file_get_contents(self::DATA_FOLDER . '/hello-world.md');

return $this->render('post.html.twig', [
'title' => 'Hello World!',
'description' => 'This is my first post.',
'content' => $content,
]);
}
}
25 changes: 25 additions & 0 deletions templates/post.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="{{ app.request.locale }}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="view-transition" content="same-origin">
<title>{{ title }}</title>
<meta name="description" content="{{ description }}">
<link rel="icon" href="/favicon.ico">
<link rel="stylesheet" href="{{ asset('vendor/bootstrap/dist/css/bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ asset('styles/app.css') }}">
<script src="{{ asset('js/pages/apply_settings.js') }}"></script>
</head>
<body>
{% include 'partial/nav.html.twig' %}
<div class="the-content container">
<div class="row">
{% apply markdown_to_html %}
{{ content | raw }}
{% endapply %}
</div>
</div>
{% include 'partial/footer.html.twig' %}
<script type="module" src="{{ asset('vendor/bootstrap/dist/js/bootstrap.bundle.min.js') }}"></script>
</body>

0 comments on commit c197f09

Please sign in to comment.