在页面加载开始时,我将JSON-LD数据添加到标题:
$allUserNames = explode(',', $userNames);
$validUserNames = Contact::whereIn('user_name', $allUserNames)
->pluck('user_name')
->toArray();
$invalidUserNames = array_values(array_diff($allUserNames, $validUserNames));
后来我收到了一些我想要添加的额外异步数据,因为Google is able to crawl it。
想知道如何更改标题中现有的JSON-LD数据?
答案 0 :(得分:1)
您可以使用react-helmet
并渲染架构脚本:
import { Helmet } from "react-helmet";
const schema = {
"@context": "http://schema.org",
"@type": "Person",
"name": "John Doe"
...
}
<Helmet>
<script type="application/ld+json">
{JSON.stringify(schema)}
</script>
</Helmet>