trinityrank / laravel-schema-org-builder
Schema.org 构建器。创建多个节点并在它们之间建立关系。
v3.5.5
2024-05-31 10:22 UTC
Requires
- php: ^8.0
- spatie/schema-org: ^3.10
README
此包用于根据 Schema.org 上给出的规则以 JSON-LD 格式构建 schema。用户可以传递节点属性以创建 schema。节点之间的关系也将被创建。
安装
您可以通过 composer 安装此包
composer require trinityrank/laravel-schema-org-builder
用法
使用 Trinityrank\LaravelSchemaOrgBuilder\SchemaOrgBuilder
。为了方便使用,在每个类中,您应该在 __construct()
中初始化它
public function __construct() { $this->schema_builder = new SchemaOrgBuilder(); }
要构建 schema,您需要调用接受以下参数的 getSchemaOrg(...)
函数
$entity - entity containing all the information, for which the schema is being built
$node_properties - specific schema nodes for given entity, that should be created during this proces. At the end of this code block an example is given, containing nodes for some of the entities.
$config - this parameter is optional. If available, here you should pass additional data in form of an array. At the moment available options are 'seo' and 'breadcrumbs'.
Example for '$node_properties':
[
'home' => ['Organization', 'WebSite', 'WebPage'],
'blog' => ['Organization', 'WebSite', 'WebPage', 'Article'],
'news' => ['Organization', 'WebSite', 'WebPage', 'Article'],
'money-page' => ['Organization', 'WebSite', 'WebPage', 'MoneyPage'],
'review' => ['Organization', 'WebSite', 'WebPage', 'Review'],
'blog-category' => ['Organization', 'WebSite', 'CollectionPage'],
'blog-archive' => ['Organization', 'WebSite', 'CollectionPage'],
'news-category' => ['Organization', 'WebSite', 'CollectionPage'],
'news-archive' => ['Organization', 'WebSite', 'CollectionPage'],
'reviews-category' => ['Organization', 'WebSite', 'CollectionPage'],
'reviews-archive' => ['Organization', 'WebSite', 'CollectionPage'],
'money-page-category' => ['Organization', 'WebSite', 'CollectionPage'],
]
部分数据是从配置文件中检索的。
从 main.php
- main.seo.home.meta_description
- main.mail_address
在 .env
中添加 FOUNDING_DATE=
(FOUNDING_DATE=2019-11-29)。如果没有添加,则默认值为 01.01.2020
从包的配置文件 schema-org-builder.php
中,您应该使用 php artisan vendor:publish --tag="schema-org-builder"
发布
- schema-org-builder.general.logo
- schema-org-builder.general.name
- schema-org-builder.sameAs
- schema-org-builder.slogan
- schema-org-builder.general.inLanguage
更新日志
请参阅更新日志以获取有关最近更改的更多信息。
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅许可证文件。