Fix homepage title when `auto_landing` is disabled fixes #456

This commit is contained in:
Stéphane Goetz 2017-05-16 23:17:06 +02:00
parent 30b6b2c2d4
commit ea61ca0210
3 changed files with 20 additions and 7 deletions

View File

@ -5,6 +5,11 @@ use Todaymade\Daux\Format\HTML\Config as HTMLConfig;
class Config extends BaseConfig
{
public function getTitle()
{
return $this['title'];
}
public function getCurrentPage()
{
return $this['current_page'];

View File

@ -9,11 +9,6 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
private function isHomepage()
{
// If we don't have the auto_landing parameter, we don't want any homepage
if (array_key_exists('auto_landing', $this->params['html']) && !$this->params['html']['auto_landing']) {
return false;
}
// If the current page isn't the index, no chance it is the landing page
if ($this->file->getParent()->getIndexPage() != $this->file) {
return false;
@ -23,6 +18,15 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
return $this->file->getParent() instanceof Root;
}
private function isLanding() {
// If we don't have the auto_landing parameter, we don't want any homepage
if (array_key_exists('auto_landing', $this->params['html']) && !$this->params['html']['auto_landing']) {
return false;
}
return $this->homepage;
}
private function initialize()
{
$this->homepage = $this->isHomepage();
@ -91,12 +95,16 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
if ($page['breadcrumbs']) {
$page['breadcrumb_trail'] = $this->getBreadcrumbTrail($this->file->getParents(), $params->isMultilanguage());
$page['breadcrumb_separator'] = $params['html']['breadcrumb_separator'];
if ($this->homepage) {
$page['breadcrumb_trail'] = [$this->file->getTitle() => ''];
}
}
$context = ['page' => $page, 'params' => $params];
$template = new Template($params['templates'], $params['theme']['templates']);
return $template->render($this->homepage ? 'theme::home' : 'theme::content', $context);
return $template->render($this->isLanding() ? 'theme::home' : 'theme::content', $context);
}
}

View File

@ -117,7 +117,7 @@ class Builder
if ($entry->getUri() == $config['index_key']) {
if ($parent instanceof Root) {
$entry->setTitle($config['title']);
$entry->setTitle($config->getTitle());
} else {
$entry->setTitle($parent->getTitle());
}