From d5f4352fdcbb12930f65588a62e80f5f82f48308 Mon Sep 17 00:00:00 2001 From: Mats Mikkel Rummelhoff <mail@mmikkel.no> Date: Mon, 27 Feb 2023 13:12:36 +0100 Subject: [PATCH] Fix template exception in SEO preview. Bump to 2.1.1 --- CHANGELOG.md | 4 ++++ composer.json | 2 +- src/templates/_previews/google/default.twig | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 908d6db..84614db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # SEOMate Changelog +## 2.1.1 - 2023-02-27 +### Fixed +- Fixes a template exception that could be thrown when rendering SEO previews + ## 2.1.0 - 2023-02-15 ### Added - Custom meta templates and template overrides are now supported in SEO previews (#28) diff --git a/composer.json b/composer.json index 621f5ad..e7b5f5a 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "vaersaagod/seomate", "description": "SEO, mate! It's important.", "type": "craft-plugin", - "version": "2.1.0", + "version": "2.1.1", "keywords": [ "craft", "cms", diff --git a/src/templates/_previews/google/default.twig b/src/templates/_previews/google/default.twig index b14743b..1558a4e 100644 --- a/src/templates/_previews/google/default.twig +++ b/src/templates/_previews/google/default.twig @@ -1,12 +1,22 @@ +{% set title = meta.title|default %} +{% set url = meta.url|default %} +{% set description = meta.description|default %} + <div class="Google__default"> <div class="Google__title"> - {{ meta.title|striptags|raw }} + {% if title %} + {{ title|striptags|raw }} + {% endif %} </div> <div class="Google__url"> - {{ entry.url | length > 85 ? entry.url[:85] ~ '...' : entry.url }} + {% if url %} + {{ url | length > 85 ? url[:85] ~ '...' : url }} + {% endif %} </div> <div class="Google__description"> - {{ (meta.description | length > 150 ? meta.description[:150] ~ '...' : meta.description)|striptags|raw }} + {% if description %} + {{ (description | length > 150 ? description[:150] ~ '...' : description)|striptags|raw }} + {% endif %} </div> </div>