Skip to content

Commit

Permalink
fix: site.page variable if multilingual is false
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny committed Nov 6, 2023
1 parent 07f6277 commit 9c61ed3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Renderer/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,25 @@ public function offsetUnset($offset): void
}

/**
* Returns a page in the current language or the one provided.
* Returns a page for the provided language or the current one provided.
*
* @throws \DomainException
*/
public function getPage(string $id, string $language = null): ?CollectionPage
{
$pageId = $id;
if ($language === null && $this->language != $this->config->getLanguageDefault()) {
$pageId = sprintf('%s/%s', $this->language, $id);
}
$language = $language ?? $this->language;

if ($language !== null && $language != $this->config->getLanguageDefault()) {
$pageId = "$language/$id";
}

if ($this->builder->getPages()->has($pageId) === false) {
// if multilingual == false
if ($this->builder->getPages()->has($id) && $this->builder->getPages()->get($id)->getVariable('multilingual') === false) {
return $this->builder->getPages()->get($id);
}

return null;
}

Expand Down

0 comments on commit 9c61ed3

Please sign in to comment.