Last active
October 9, 2019 07:59
-
-
Save Sebobo/0f08bfdb9576aaacaa0ecede6701494a to your computer and use it in GitHub Desktop.
Structured data tags in Neos CMS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prototype(Neos.Seo:StructuredData.RootObject) < prototype(Neos.Seo:StructuredData.Object) { | |
context = 'http://schema.org' | |
@process.toJson = ${Json.stringify(value)} | |
@process.wrap = ${'<script type="application/ld+json">' + value + '</script>'} | |
} | |
prototype(Neos.Seo:StructuredData.Object) < prototype(Neos.Fusion:Component) { | |
// Optional context. Usually "http://schema.org" for root objects | |
context = '' | |
// The required `schema.org` type for this object | |
type = '' | |
// Inherit props from parent object into data. These can be accessed in the renderer via props.data. | |
data = ${props} | |
// All attributes will be applied to the resulting object | |
attributes = Neos.Fusion:DataStructure | |
renderer = Neos.Fusion:DataStructure { | |
'@context' = ${props.context} | |
'@context'[email protected] = ${props.context} | |
'@type' = ${props.type} | |
@apply.attributes = ${props.attributes ? Array.filter(props.attributes, attribute => attribute != null) : []} | |
} | |
@if.hasType = ${this.type} | |
} | |
prototype(Neos.Seo:StructuredData.Breadcrumb) < prototype(Neos.Fusion:Component) { | |
items = ${q(documentNode).add(q(documentNode).parents('[instanceof Neos.Neos:Document]')).get()} | |
[email protected] = ${Array.reverse(value)} | |
renderer = afx` | |
<Neos.Seo:StructuredData.RootObject type="BreadcrumbList"> | |
<Neos.Fusion:Map items={props.items} iterationName="iteration" @path="attributes.itemListElement"> | |
<Neos.Seo:StructuredData.Object type="ListItem" attributes.position={iteration.cycle} attributes.name={item.label}> | |
<Neos.Neos:NodeUri node={item} absolute={true} @path="attributes.item"/> | |
</Neos.Seo:StructuredData.Object> | |
</Neos.Fusion:Map> | |
</Neos.Seo:StructuredData.RootObject> | |
` | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prototype(Neos.Fusion:DataStructureComponent) < prototype(Neos.Fusion:Component) { | |
prototype(Neos.Fusion:Tag) { | |
@class = 'Neos\\Fusion\\FusionObjects\\DataStructureImplementation' | |
@ignoreProperties = ${['tagName', 'content', 'attributes', 'selfClosingTag', 'omitClosingTag']} | |
'@type' = ${this.tagName} | |
} | |
@process { | |
setContext = ${Array.set(value, '@context', 'http://schema.org')} | |
toJson = ${Json.stringify(value)} | |
wrap = ${'<script type="application/ld+json">' + value + '</script>'} | |
} | |
} | |
prototype(Neos.Seo:StructuredData.Breadcrumb) < prototype(Neos.Fusion:DataStructureComponent) { | |
items = ${q(documentNode).add(q(documentNode).parents('[instanceof Neos.Neos:Document]')).get()} | |
[email protected] = ${Array.reverse(value)} | |
renderer = afx` | |
<BreadcrumbList> | |
<Neos.Fusion:Map items={props.items} iterationName="iteration" @path="itemListElement"> | |
<ListItem position={iteration.cycle} name={item.label}> | |
<Neos.Neos:NodeUri node={item} absolute={true} @path="item"/> | |
</ListItem> | |
</Neos.Fusion:Map> | |
</BreadcrumbList> | |
` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment