Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions export/app/Tags/LuckySeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ public function title()
$title = $this->context->get('seo_custom_meta_title');
}

if ($append) {
return "$title - $append";
}

if($prepend) {
return "$prepend - $title";
if ($append || $prepend) {
return ($prepend ? "$prepend - " : '') . "$title" . ($append ? " - $append" : '');
}

return $title;
Expand All @@ -51,7 +47,7 @@ public function description()
return $this->context->get('seo_custom_meta_description');
}

return null;
return null;
}

/**
Expand All @@ -61,7 +57,23 @@ public function description()
*/
public function canonical()
{
return $this->context->raw('seo_canonical') ? $this->context->get('seo_canonical') : $this->context->get('permalink');
$value = $this->context->get('seo_canonical');

$resolved = $value?->value();

if ($resolved instanceof \Statamic\Fieldtypes\Link\ArrayableLink) {
$entry = $resolved->value();

if ($entry instanceof \Statamic\Entries\Entry) {
return $entry->absoluteUrl();
}

if (is_string($entry)) {
return $entry;
}
}

return $this->context->get('permalink');
}

/**
Expand Down Expand Up @@ -128,7 +140,7 @@ public function twTitle()
*/
public function twDescription()
{
$desc_config = $this->context->raw('seo_og_description');
$desc_config = $this->context->raw('seo_tw_description');

if ($desc_config === 'meta') {
return $this->description();
Expand All @@ -140,7 +152,7 @@ public function twDescription()
}

if($desc_config === 'custom') {
return $this->context->get('seo_custom_og_desc');
return $this->context->get('seo_custom_tw_desc');
}

return null;
Expand Down