From 69b6ce2724bfc4d472192835cb1fa213b395a8a9 Mon Sep 17 00:00:00 2001 From: Awilum Date: Sun, 18 Mar 2018 23:31:29 +0300 Subject: [PATCH] Pages class improvements --- rawilum/Pages.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/rawilum/Pages.php b/rawilum/Pages.php index 490c4c8d..ce663ec0 100755 --- a/rawilum/Pages.php +++ b/rawilum/Pages.php @@ -111,6 +111,21 @@ class Pages $frontmatter = Shortcodes::parse($page[1]); $result_page = Yaml::parse($frontmatter); + + // Get page url + $url = str_replace(PAGES_PATH, Url::getBase(), $file); + $url = str_replace('index.md', '', $url); + $url = str_replace('.md', '', $url); + $url = str_replace('\\', '/', $url); + $url = rtrim($url, '/'); + $result_page['url'] = $url; + + // Get page slug + $url = str_replace(Url::getBase(), '', $url); + $url = ltrim($url, '/'); + $url = rtrim($url, '/'); + $result_page['slug'] = str_replace(Url::getBase(), '', $url); + $result_page['content'] = $page[2]; return $result_page; @@ -149,14 +164,18 @@ class Pages /** * getPage */ - public static function getPages($url = '', $raw = false, $order_by = 'title', $order_type = 'DESC', $ignore = ['404', 'index'], $limit = null) + public static function getPages($url = '', $raw = false, $order_by = 'title', $order_type = 'DESC', $limit = null) { // Get pages list for current $url $pages_list = Rawilum::$finder->files()->name('*.md')->in(PAGES_PATH . '/' . $url); // Go trough pages list foreach ($pages_list as $key => $page) { - $pages[$key] = static::getPage($page->getPathname(), $raw, true); + if (strpos($page->getPathname(), $url.'/index.md') !== false) { + + } else { + $pages[$key] = static::getPage($page->getPathname(), $raw, true); + } } // Sort and Slice pages if !$raw