Fix and simplify homepage detection in HTML generator
This commit is contained in:
parent
a13469047a
commit
e70461b641
@ -1,5 +1,8 @@
|
|||||||
<?php namespace Todaymade\Daux\Format\HTML;
|
<?php namespace Todaymade\Daux\Format\HTML;
|
||||||
|
|
||||||
|
use Todaymade\Daux\Daux;
|
||||||
|
use Todaymade\Daux\Tree\Root;
|
||||||
|
|
||||||
class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage
|
class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage
|
||||||
{
|
{
|
||||||
private $language;
|
private $language;
|
||||||
@ -8,13 +11,13 @@ class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage
|
|||||||
private function initialize()
|
private function initialize()
|
||||||
{
|
{
|
||||||
$this->homepage = false;
|
$this->homepage = false;
|
||||||
if ($this->title === 'index') {
|
if ($this->file->getParent()->getIndexPage() == $this->file) {
|
||||||
$minimum_parent_dir_size = ($this->params['multilanguage']) ? 2 : 1;
|
if ($this->params['multilanguage']) {
|
||||||
if (count($this->file->getParents()) >= $minimum_parent_dir_size) {
|
if ($this->file->getParent()->getParent() instanceof Root) {
|
||||||
$this->title = $this->file->getParent()->getTitle();
|
$this->homepage = true;
|
||||||
} else {
|
}
|
||||||
$this->homepage = ($this->file->getName() === '_index');
|
} elseif ($this->file->getParent() instanceof Root) {
|
||||||
$this->title = $this->params['title'];
|
$this->homepage = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +53,7 @@ class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage
|
|||||||
$params = $this->params;
|
$params = $this->params;
|
||||||
|
|
||||||
$entry_page = [];
|
$entry_page = [];
|
||||||
if ($params['request'] === $params['index_key']) {
|
if ($this->homepage) {
|
||||||
if ($params['multilanguage']) {
|
if ($params['multilanguage']) {
|
||||||
foreach ($params['languages'] as $key => $name) {
|
foreach ($params['languages'] as $key => $name) {
|
||||||
$entry_page[$name] = $params['base_page'] . $params['entry_page'][$key]->getUrl();
|
$entry_page[$name] = $params['base_page'] . $params['entry_page'][$key]->getUrl();
|
||||||
@ -58,8 +61,6 @@ class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage
|
|||||||
} else {
|
} else {
|
||||||
$entry_page['View Documentation'] = $params['base_page'] . $params['entry_page']->getUrl();
|
$entry_page['View Documentation'] = $params['base_page'] . $params['entry_page']->getUrl();
|
||||||
}
|
}
|
||||||
} elseif ($params['file_uri'] === 'index') {
|
|
||||||
$entry_page[$params['entry_page']->getTitle()] = $params['base_page'] . $params['entry_page']->getUrl();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = [
|
$page = [
|
||||||
|
Loading…
Reference in New Issue
Block a user