Faire un blog avec Stenope
src/Model/Article.php
namespace App\Model;
class Article {
public string $slug;
public string $title;
public string $content;
public \DateTimeInterface $publication;
}
content/articles/top-10-jeux-video-indé.md
---
title: "Mon top 10 des jeux video indépendants"
publication: "16-04-2021"
---
## Jeux naratifs
- Firewatch
- Stories Untold
- Inside
- Kentucky Route Zero
- The vanishing of Ethan Carter
- The witness
- Journey
- What Remains of Edith Finch
- Return of the Obra Dinn
- Subnautica
config/packages/stenope.yaml
stenope:
providers:
local_articles:
class: 'App\Model\Article'
type: 'files'
path: '%kernel.project_dir%/content/articles'
src/Controller/BlogController
use App\Model\Article;
use Stenope\Bundle\ContentManager;
class BlogController {
/**
* @Route("/", name="blog")
*/
public function index(ContentManager $manager)
{
$articles = $manager->getContents(Article::class);
return $this->render(
'blog/index.html.twig',
['articles' => $articles]
);
}
}
src/Controller/BlogController
//...
/**
* @Route("/{slug}", name="article")
*/
public function article(string $slug)
{
$article = $this->manager->getContent(Article::class, $slug);
return $this->render(
'blog/article.html.twig',
['article' => $article]
);
}