Skip to content

Commit

Permalink
Adds a simple way to add canonical links from Antlers templates
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnathonKoster committed Dec 10, 2023
1 parent ce2f941 commit 9aa3635
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Tags/Metadata/SeMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ public function index(): string
return $this->metadataManager->toHtml($contextValues, $additionalMeta);
}

public function canonical(): void
{
$onlyOnQuery = $this->params->get('only_on_query', false);

if ($onlyOnQuery && count(request()->input()) == 0) {
return;
}

Metadata::ephemeral(function (MetaBuilder $meta) {
$meta->general()->canonical($this->params->get('url', request()->url()));
});
}

public function paginate(): void
{
$paginate = $this->context->get('paginate', null);
Expand Down

0 comments on commit 9aa3635

Please sign in to comment.