georgringer/schema-org-generator

根据 schema org 生成 json-ld

0.3.0 2022-04-26 10:31 UTC

This package is auto-updated.

Last update: 2024-09-13 08:14:10 UTC


README

此扩展从模型生成 json-ld,目前仅是一个 PoC。

安装

  • 执行 composer require spatie/schema-org
  • 安装此扩展

需求

  • TYPO3 10,11,12
  • PHP 7.2+

使用

基本使用

在您的网站模板中,您可以编写

<schema:jsonLd type="webSite" data="{url:'https://www.tld.com'}" />

这将输出

<script type="application/ld+json">
    {"@context":"https:\/\/schema.org","@type":"WebSite","url":"https:\/\/www.tld.com"}
</script>

类型可以使用在 https://github.com/spatie/schema-org/tree/master/src 中提供的任何类型

将模型映射到 json+ld

目前仅支持 tt_address。将以下代码片段添加到您的 ListItem.html:目前它仅输出属性 email

<schema:objectToJsonLd object="{address}" />

这将输出

<script type="application/ld+json">
    {"@context":"https:\/\/schema.org","@graph":[{"@type":"PostalAddress","email":"mailus@email.com"}]}
</script>