Skip to content

Commit 36942bc

Browse files
committed
BUGFIX: Set canonical to original node on non translated pages
1 parent 5965f9a commit 36942bc

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Neos\NeosIo\Eel\Helper;
5+
6+
use Neos\ContentRepository\Core\DimensionSpace\AbstractDimensionSpacePoint;
7+
use Neos\Eel\ProtectedContextAwareInterface;
8+
9+
class NodeHelper implements ProtectedContextAwareInterface
10+
{
11+
12+
/** @return array<string,array<int,string>> */
13+
public function dimensionSpacePointArray(AbstractDimensionSpacePoint $dimensionSpacePoint): array
14+
{
15+
return $dimensionSpacePoint->toLegacyDimensionArray();
16+
}
17+
18+
/**
19+
* @param string $methodName
20+
*/
21+
public function allowsCallOfMethod($methodName): bool
22+
{
23+
return true;
24+
}
25+
}

DistributionPackages/Neos.NeosIo/Configuration/Settings.Fusion.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ Neos:
44
Data: Neos\NeosIo\Eel\Helper\DataHelper
55
NeosIo_Event: Neos\NeosIo\Eel\Helper\EventHelper
66
Gravatar: Neos\NeosIo\Eel\Helper\GravatarHelper
7+
NeosIo.Node: Neos\NeosIo\Eel\Helper\NodeHelper

DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Overrides/Override.Seo.fusion

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,16 @@ prototype(Neos.Seo:AlternateLanguageLink) {
2626
@if.hasMetaRobotsNoIndexNotSet = ${q(this.node).property('metaRobotsNoindex') || q(this.node).is('[instanceof Neos.Seo:NoindexMixin]') ? false : true}
2727
@if.hasNoForeignCanonical = ${String.isBlank(q(this.node).property('canonicalLink'))}
2828
}
29+
30+
prototype(Neos.Seo:CanonicalLink) {
31+
attributes.href.node = Neos.Fusion:Case {
32+
useFallback {
33+
condition = ${node.originDimensionSpacePoint != node.dimensionSpacePoint}
34+
renderer = ${q(node).context({dimensions: NeosIo.Node.dimensionSpacePointArray(node.originDimensionSpacePoint)}).get(0)}
35+
}
36+
default {
37+
condition = true
38+
renderer = ${node}
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)