October CMS JSON-LD components for schema.org with nesting support.
Based on schema.org version 9.0 WITHOUT pending schemas and properties.
This plugin adds component for many of the https://schema.org schemas.
List of currently supported schemas and enumerations
Add component to your layout or page and configure it
Render it using the component syntax
{% component 'Thing' %}
Component should render this code:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Thing",
"description": "Example description",
"name": "Example name"
}
</script>
IMPORTANT 1: Currently there are no checks performed to ensure that circular dependencies are not happening. Have that in mind when referencing one component in another.
IMPORTANT 2: Currently there is no support for referencing multiple components in one field, but it is planned to do.
IMPORTANT 3: When you reference component which does not exist in the page or layout exception will be thrown.
IMPORTANT 4: When you reference component which is not a valid JSON-LD component exception will be thrown.
This plugin supports referencing components inside other components if there are added to the same page or to the currently used layout.
To do to you need to use following syntax:
page:componentAlias
layout:componentAlias
ImageObject | Thing |
---|---|
Insert code into your template:
{% component 'Thing' %}
Component should render this code:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Thing",
"description": "Example description",
"image": {
"@type": "ImageObject",
"caption": "Image caption"
},
"name": "Example name"
}
</script>
If you want to have multiple values for one of the properties just separate values using semicolon. Referencing multiple components with this syntax is also supported.
Writing 250ml of milk; 2 eggs; banana
in one of the component parameters will results in the
array of data being rendered into JSON like so
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Recipe",
"recipeIngredient": [
"250ml of milk",
"egg",
"banana"
]
}
</script>
Writing page:componentAlias1; layout:componentAlias2
in one of the component parameters will result
in the array of data being rendered into JSON like so
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Menu",
"hasMenuItem": [
{
"@type": "MenuItem",
"name": "First menu item"
},
{
"@type": "MenuItem",
"name": "Second menu item"
}
]
}
</script>