diff --git a/about.page b/about.page index c242afd..02d44de 100755 --- a/about.page +++ b/about.page @@ -4,7 +4,7 @@ description: Convert file and folder structure into web pages. icon: 'M19 2L14 6.5V17.5L19 13V2M6.5 5C4.55 5 2.45 5.4 1 6.5V21.16C1 21.41 1.25 21.66 1.5 21.66C1.6 21.66 1.65 21.59 1.75 21.59C3.1 20.94 5.05 20.5 6.5 20.5C8.45 20.5 10.55 20.9 12 22C13.35 21.15 15.8 20.5 17.5 20.5C19.15 20.5 20.85 20.81 22.25 21.56C22.35 21.61 22.4 21.59 22.5 21.59C22.75 21.59 23 21.34 23 21.09V6.5C22.4 6.05 21.75 5.75 21 5.5V19C19.9 18.65 18.7 18.5 17.5 18.5C15.8 18.5 13.35 19.15 12 20V6.5C10.55 5.4 8.45 5 6.5 5Z' author: Taufik Nurrohman type: Markdown -version: 2.0.3 +version: 2.1.0 use: '.\lot\x\layout': 1 diff --git a/engine/kernel/page.php b/engine/kernel/page.php index 1eef48f..058a6d1 100644 --- a/engine/kernel/page.php +++ b/engine/kernel/page.php @@ -139,6 +139,18 @@ public function offsetUnset($key): void { unset($this->cache[$key], $this->lot[$key]); } + public function parent(array $lot = []) { + if (!$this->exist()) { + return null; + } + $folder = dirname($this->path); + $path = exist([ + $folder . '.archive', + $folder . '.page' + ], 1); + return $path ? new static($path, $lot) : null; + } + public function time(string $format = null) { $name = parent::name(); // Set `time` value from the page’s file name diff --git a/index.php b/index.php index ffecc3a..24a445f 100755 --- a/index.php +++ b/index.php @@ -87,9 +87,9 @@ function route($content, $path, $query, $hash) { $folder . '.page' ], 1)) { $page = new \Page($file); - $pager = new \Pager\Page([], null, (object) [ + $pager = new \Pager\Page([], null, new \Page(null, [ 'link' => $path ? $url . "" : null - ]); + ])); $chunk = $page['chunk'] ?? 5; $deep = $page['deep'] ?? 0; $sort = $page['sort'] ?? [1, 'path']; @@ -136,9 +136,9 @@ function route($content, $path, $query, $hash) { return ['page', [], 200]; } // Create pager for “pages” mode - $pager = new \Pager\Pages($pages->get(), [$chunk, $i], (object) [ + $pager = new \Pager\Pages($pages->get(), [$chunk, $i], new \Page(null, [ 'link' => $url . '/' . ($path ?: $route) - ]); + ])); // Disable parent link in root page if (!$path || false === \strpos($path, '/') && $i < 1) { $pager->parent = null;