Skip to content

Commit

Permalink
Added categories (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
codecat authored Dec 29, 2024
1 parent 7b4eb90 commit bd48c73
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 5 deletions.
11 changes: 8 additions & 3 deletions components/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private function getPageIndexInternal(string|null $docs_dir = null)

$roots[] = [
'type' => 'root',
'category' => $root_index_page->meta['category'] ?? '',
'name' => $root_index_page->meta['name'] ?? str_replace('-', ' ', ucfirst($root)),
'icon' => $index_page->meta['icon'] ?? '',
'path' => $root,
Expand All @@ -76,8 +77,9 @@ private function getPageIndexInternal(string|null $docs_dir = null)

$dirs[] = [
'type' => 'dir',
'category' => $dir_index_page->meta['category'] ?? '',
'name' => $dir_index_page->meta['name'] ?? str_replace('-', ' ', ucfirst($dir)),
'icon' => $index_page->meta['icon'] ?? '',
'icon' => $dir_index_page->meta['icon'] ?? '',
'path' => $dir,
'children' => $this->getPageIndexInternal($docs_dir . '/' . $dir),
];
Expand All @@ -95,6 +97,7 @@ private function getPageIndexInternal(string|null $docs_dir = null)

$pages[] = [
'type' => 'page',
'category' => $page->meta['category'] ?? '',
'name' => $page->getName(),
'icon' => $page->meta['icon'] ?? '',
'path' => $page_name,
Expand Down Expand Up @@ -123,6 +126,7 @@ private function getPageIndexInternal(string|null $docs_dir = null)
if ($fileinfo->isDir()) {
$dirs[] = [
'type' => 'dir',
'category' => '',
'name' => str_replace('-', ' ', ucfirst($filename)),
'icon' => '',
'path' => $filename,
Expand All @@ -143,6 +147,7 @@ private function getPageIndexInternal(string|null $docs_dir = null)

$pages[] = [
'type' => 'page',
'category' => $page->meta['category'] ?? '',
'name' => $page->getName(),
'icon' => $page->meta['icon'] ?? '',
'path' => $filename,
Expand All @@ -155,9 +160,9 @@ private function getPageIndexInternal(string|null $docs_dir = null)

public function getPageIndex()
{
return nf_cache()->take('page_index', 3600, function() {
//return nf_cache()->take('page_index', 3600, function() {
return $this->getPageIndexInternal();
});
//});
}

public function getPageIndexInfo(string $path)
Expand Down
2 changes: 2 additions & 0 deletions docs/auth/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
name: Authentication
category: general
icon: fa-lock
pages:
- ubi
- dedi
Expand Down
1 change: 1 addition & 0 deletions docs/core/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Core API
category: reference
---

# Core API
Expand Down
1 change: 1 addition & 0 deletions docs/glossary.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
icon: "fa-book"
category: "general"
---

# Glossary
Expand Down
1 change: 1 addition & 0 deletions docs/live/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Live API
category: reference
---

# Live API
Expand Down
1 change: 1 addition & 0 deletions docs/meet/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Meet API
category: reference
---

# Meet API
Expand Down
4 changes: 2 additions & 2 deletions views/menu/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
]);

foreach ($index as $item) {
if ($item['type'] != 'page') {
if ($item['category'] != 'general') {
continue;
}
echo $this->renderPartial('/menu/item', [
Expand All @@ -28,7 +28,7 @@
<ul class="menu-list">
<?php
foreach ($index as $item) {
if ($item['type'] != 'dir') {
if ($item['category'] != 'reference') {
continue;
}
echo $this->renderPartial('/menu/item', [
Expand Down

0 comments on commit bd48c73

Please sign in to comment.