redesign nav and logo

This commit is contained in:
isUnknown 2024-11-26 09:53:05 +01:00
parent 48bfd23600
commit cf867bbc14
14 changed files with 315 additions and 297 deletions

View file

@ -1,41 +1,44 @@
<?php
function createCategories($textsPage) {
$categories = array();
foreach ($textsPage->categories()->split() as $category) {
$categories[$category] = array(
'title' => $category,
'texts' => new Pages()
);
}
function createEmptyCategories() {
$categories = new Pages();
foreach (page('textes')->categories()->split() as $categoryName) {
$category = new Page([
'slug' => Str::slug($categoryName),
'template' => 'category',
'status' => 'listed',
'content' => [
'title' => $categoryName,
],
'children' => []
]);
$categories->add($category);
}
return $categories;
}
function fillCategoriesWithTexts($emptyCategories, $texts) {
$filledCategories = $emptyCategories;
foreach ($texts as $text) {
function createCategories() {
$emptyCategories = createEmptyCategories();
foreach (page('textes')->grandChildren() as $text) {
try {
$textCategory = $text->category()->value();
$filledCategories[$textCategory]['texts']->add($text);
$textCategoryName = $text->category()->value();
$emptyCategories
->findBy('slug', Str::slug($textCategoryName))
->children()
->add($text);
} catch (\Throwable $th) {
throw new Exception(json_encode($th->getFile() . ' : ' . $th->getMessage()));
throw new Exception($th->getFile() . ' : ' . $th->getMessage());
}
}
// exclude empty categories
return array_filter($filledCategories, function($category) {
return count($category['texts']) > 0;
return $emptyCategories->filter(function ($category) {
return $category->children()->count() > 0;
});
}
return function ($site) {
$textsPage = $site->find('textes');
$years = $textsPage->children();
$texts = $years->children()->index();
$emptyCategories = createCategories($textsPage);
$filledCategories = fillCategoriesWithTexts($emptyCategories, $texts);
return $filledCategories;
$categories = createCategories();
return $categories;
};