diff --git a/README.md b/README.md index 9ec4ce3..0646e02 100755 --- a/README.md +++ b/README.md @@ -266,11 +266,11 @@ If your server does not have a default timezone set in php.ini, it may return er ``` ###Inherit Index -This feature will insruct the router to seek the first available file to use when a request to a folder is made and the index is not found. +This feature will instructs the navigation generator to seek the first available file to use when there is no index in a folder. ```json { - "live": { + "html": { "inherit_index": true } } diff --git a/docs/config.json b/docs/config.json index 745e912..34a01d7 100644 --- a/docs/config.json +++ b/docs/config.json @@ -8,7 +8,6 @@ "folders": ["99_Not_Ready"] }, "live": { - "inherit_index": true, "clean_urls": true }, "html": { @@ -18,6 +17,7 @@ "toggle_code": true, "date_modified": true, "float": true, + "inherit_index": true, "repo": "justinwalsh/daux.io", "twitter": ["justin_walsh", "todaymade"], diff --git a/global.json b/global.json index 6c93a79..3633948 100644 --- a/global.json +++ b/global.json @@ -19,7 +19,6 @@ "timezone": "America/Los_Angeles", "live": { - "inherit_index": false, "clean_urls": false }, @@ -32,6 +31,7 @@ "auto_landing": true, "search": true, "auto_toc": false, + "inherit_index": false, "repo": "", "twitter": [], diff --git a/libs/Config.php b/libs/Config.php index 57a50b1..f9e60f7 100644 --- a/libs/Config.php +++ b/libs/Config.php @@ -87,4 +87,17 @@ class Config extends ArrayObject { return array_key_exists('languages', $this) && !empty($this['languages']); } + + public function shouldInheritIndex() + { + if (array_key_exists('html', $this) && array_key_exists('inherit_index', $this['html'])) { + return $this['html']['inherit_index']; + } + + if (array_key_exists('live', $this) && array_key_exists('inherit_index', $this['live'])) { + return $this['live']['inherit_index']; + } + + return false; + } } diff --git a/libs/Format/HTML/Template.php b/libs/Format/HTML/Template.php index e845401..dd245c8 100644 --- a/libs/Format/HTML/Template.php +++ b/libs/Format/HTML/Template.php @@ -133,12 +133,8 @@ class Template 'class' => strpos($current_url, $link) === 0 ? 'Nav__item--open' : '', ]; - if ($mode === Daux::STATIC_MODE) { - $link .= '/index.html'; - } - - if ($node->getIndexPage()) { - $folder['href'] = $base_page . $link; + if ($index = $node->getIndexPage()) { + $folder['href'] = $base_page . $index->getUrl(); } //Child pages diff --git a/libs/Tree/Directory.php b/libs/Tree/Directory.php index 88b987d..461befc 100644 --- a/libs/Tree/Directory.php +++ b/libs/Tree/Directory.php @@ -120,13 +120,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate return $this->children[$index_key]; } - /* - If the inherit_index flag is set, then we seek child content - */ - if ($this->getConfig()['mode'] == Daux::LIVE_MODE - && !empty($this->getConfig()['live']['inherit_index']) - && $first_page = $this->seekFirstPage() - ) { + if ($this->getConfig()->shouldInheritIndex() && $first_page = $this->seekFirstPage()) { return $first_page; }