Skip to content

Commit

Permalink
Fix url when using prefixDefaultLocale=true (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin authored May 31, 2023
1 parent df39163 commit 600c9ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ function (DefinitionItem $item, array $itemInfo, Definition $definition, DOMDocu
}
foreach ($itemInfo['alternateLinks'] as $locale => $altUrl) {
if ($locale === $defaultLocale->code) {
$loc = $urlElement->getElementsByTagName('loc')->item(0);
$loc->nodeValue = $altUrl;
continue;
}
$newElement = $urlElement->cloneNode(true);
Expand Down
10 changes: 2 additions & 8 deletions classes/MLPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ public static function resolveMenuItem(object $item, string $url, Theme $theme):

$alternateLinks = [];
foreach ($locales as $locale => $name) {
if ($locale === $defaultLocale->code) {
$pageUrl = $result['url'];
} else {
$pageUrl = static::getLocalizedPageUrl($page, $locale);
}
if ($pageUrl) {
$alternateLinks[$locale] = Url::to($pageUrl);
}
$pageUrl = static::getLocalizedPageUrl($page, $locale) ?: $result['url'];
$alternateLinks[$locale] = Url::to($pageUrl);
}

if ($alternateLinks) {
Expand Down

0 comments on commit 600c9ef

Please sign in to comment.