-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Glossary] Introduce terms listing & show pages
- Loading branch information
Showing
22 changed files
with
291 additions
and
35 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
name: "AWS" | ||
logo: "build/images/services/aws.svg" | ||
externalLink: https://aws.amazon.com/fr/ | ||
#metaDescription: TODO | ||
--- | ||
|
||
Some **markdown** content |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: "Exemple" | ||
logo: "build/images/technos/exemple.svg" | ||
externalLink: http://example.org | ||
|
||
# False to prevent listing it on the glossary page. | ||
# Cans till be externalLinked from articles or case studies. | ||
listInGlossary: false | ||
|
||
# Array of slugs of related articles to show on the glossary term page. | ||
# If not provided (null), will search for related articles by their tags. | ||
articles: [] | ||
|
||
metaDescription: Une description courte à utiliser dans les meta de la page | ||
--- | ||
|
||
Some **markdown** content |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
name: "OVH Cloud" | ||
logo: "build/images/services/ovh-cloud.svg" | ||
externalLink: https://www.ovhcloud.com/fr/ | ||
#metaDescription: TODO | ||
--- | ||
|
||
Some **markdown** content |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
name: "Scaleway" | ||
logo: "build/images/services/scaleway.svg" | ||
externalLink: https://www.scaleway.com/fr/ | ||
#metaDescription: TODO | ||
--- | ||
|
||
Some **markdown** content |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Controller; | ||
|
||
use App\Glossary\GlossaryBuilder; | ||
use App\Model\Article; | ||
use App\Model\CaseStudy; | ||
use App\Model\Glossary\Term; | ||
use Stenope\Bundle\ContentManagerInterface; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
#[Route('/glossaire')] | ||
class GlossaryController extends AbstractController | ||
{ | ||
private ContentManagerInterface $manager; | ||
|
||
public function __construct(ContentManagerInterface $manager) | ||
{ | ||
$this->manager = $manager; | ||
} | ||
|
||
#[Route('/', name: 'glossary')] | ||
public function glossary(GlossaryBuilder $builder): Response | ||
{ | ||
$terms = $this->manager->getContents(Term::class, 'name', ['listInGlossary' => true]); | ||
$articles = $this->manager->getContents(Article::class, ['date' => false]); | ||
|
||
return $this->render('glossary/index.html.twig', [ | ||
'glossary' => $builder->build($terms), | ||
'articles' => \array_slice($articles, 0, 4), | ||
]); | ||
} | ||
|
||
#[Route('/{term}', name: 'glossary_term')] | ||
public function show(Term $term): Response | ||
{ | ||
$articlesFilter = null !== $term->articles | ||
// Search for articles by their slug if provided | ||
? static fn ($article) => \in_array($article->slug, $term->articles, true) | ||
// otherwise by their tags matching the term slug | ||
: static fn (Article $article): bool => $article->hasTag($term->slug) | ||
; | ||
|
||
$articles = $this->manager->getContents(Article::class, ['date' => false], $articlesFilter); | ||
|
||
$caseStudies = $this->manager->getContents( | ||
CaseStudy::class, | ||
['date' => false], | ||
fn (CaseStudy $caseStudy): bool => $caseStudy->enabled && $caseStudy->hasTerm($term) | ||
); | ||
|
||
return $this->render('glossary/term.html.twig', [ | ||
'term' => $term, | ||
'articles' => \array_slice($articles, 0, 3), | ||
'caseStudies' => $caseStudies, | ||
])->setLastModified($term->lastModified); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.