I am adding event schema to an entry page. I have offer and date properties working well based on https://nystudio107.com/blog/tips-for-using-seomatic-effectively
This is working for offers
{% if entry.soldOut == '1' %}
{% set availability = 'http://schema.org/SoldOut' %}
{% else %}
{% set availability = 'http://schema.org/InStock' %}
{% endif %}
{% set offersJsonLd = seomatic.jsonLd.create({
'type': 'Offer',
'price': entry.eventPrice,
'priceCurrency': 'GBP',
'validFrom': entry.postDate|date("Y-m-d"),
'url': entry.url,
'availability': availability,
}, false) %}
{% do mainEntity.offers(offersJsonLd) %}
I can't work out the correct approach for performers though. I have a Matrix field for performers with two fields performerType and performerName
I have tried this
{% set performerJsonLd = seomatic.jsonLd.create(
{% for block in entry.performers .all() %}
{
'type': block.performerType,
'name': block.performerName,
},
{% endfor %}
false) %}
{% do mainEntity.performer(performerJsonLd) %}
and
{% set performersAndTypes %}
{% for block in entry.performers .all() %}
{
'@type': '{{ block.performerType }}',
'name': '{{ block.performerName }}',
}{% if not loop.last %},{% endif %}
{% endfor %}
{% endset %}
{% set performerJsonLd = seomatic.jsonLd.create(
performersAndTypes,
false) %}
{% do mainEntity.performer(performerJsonLd) %}
but get errors for both.
What would the correct approach be to get this working?