statamic / seo-pro

An all-in-one site reporting, metadata wrangling, Open Graph managing, Twitter card making, sitemap generating, turn-key addon for Statamic.
https://statamic.com/addons/statamic/seo-pro
53 stars 36 forks source link

Error in Documentation or Bug with Antlers Code as Description #287

Open sewid opened 1 year ago

sewid commented 1 year ago

In the seo pro docs, there is an example for antlers templating:

{{ content | strip_tags | truncate:250:... }}

If I use this example code or if I use the code below as description content:

{{ content | strip_tags | truncate(150, '...') }}

I get this error message:

strip_tags(): Argument #1 ($string) must be of type string, array given

Statamic Version is: 4.10.2 SEO Pro Version is: 5.2.1

jackmcdade commented 1 year ago

This would work if your content is a string, but my guess is you're using Bard, which stores its data in an array. In order to truncate Bard text you'd need to loop the tag, get the first text var, and truncate that.

sewid commented 1 year ago

Hi @jackmcdade , no, it's a markdown field. If I place

{{ content | strip_tags | truncate(150, '...') }}

in a template somewhere, it works without problems.

jackmcdade commented 1 year ago

Which Antlers parser are you using? You can check in config/statamic/antlers.php – you should be using runtime.

sewid commented 1 year ago

it is runtime

jackmcdade commented 1 year ago

Okay, I'm gonna have @jesseleite take a look at this, he's the SEO Pro guy and it's clear that something else is at play here 🤔

sewid commented 1 year ago

ok, thanks! 😄

jesseleite commented 1 year ago

Hey @sewid, I'm having reproducing this with a markdown field 🤔 Could you maybe provide a simple example site repo with the issue reproduced that we could pull down by chance?

sewid commented 1 year ago

Hey @jesseleite, I've sent you an email about two weeks ago where you can find the code. Have you seen it?