marker-bundle now with page sorting
In the latest v0.5.0 update to my marker-bundle for Symfony, it is possible to sort pages, eg. for when retrieving list of page names for navigation.
It is pretty simple, the same getPages() method in PageRepository now accepts a sorted parameter. Add true for sorting, defautls to false.
Take this controller example:
#[Route('/', name: 'app_index')]
public function index(
PageRepository $PageRepository,
): Response {
$templateData = [
'pages' => $PageRepository->getPages(sorted: true);
];
return $this->render('index/index.html.twig', $templateData);
}
Markdown + FrontMatter
Before, pages didn't have any metadata as posts do. The bundle has now been updated to add metaodata to both posts and pages through FrontMatter.
The console command bin/console marker:create:page will also ask for a sort order, or alternatively add it with the sort option, bin/console marker:create:page --title="Random page with sort order" --sort=42.
Using the sort attribute, pages are now sorted descesnding. Meaning what you want first, should have the highest number.
Take a look here:
---
title: 'Random page with sort order'
sort: 42
---
# Random page with sort order
Some content here.
Pretty nice if I have to say so my self...
// ASH