javascript - javascript 创建的 JSON-LD 不是结构化数据
问题描述
我正在尝试使用 javascript 为我的网站自动生成 json-ld 结构化数据。一切都很好,直到我从工具中检查,在 javascript 中生成的 json-ld 代码没有出现在测试表上。当我继续在 chrome 上查看源代码时,它不会显示 json-ld 代码。
你可以在这里看到它
代码是打击
<script id='myJSONID' type='application/ld+json'></script>
<script type='text/javascript'>
//<![CDATA[
$('#myJSONID').text(function() {
return JSON.stringify({
"@context":"https://schema.org",
"@type":"Review",
"author": {
"@type":"Person",
"name":"Nhà Gò Vấp đẹp",
"sameAs":"https://www.blogger.com/profile/14170245093404020455"
},
"url": "<data:blog.canonicalUrl/>",
"datePublished": "<data:post.dateHeader/>",
"publisher": {
"@type":"Organization",
"name":"" + document.title,
"sameAs":"<data:blog.homepageUrl/>"
},
"description":"" + document.getElementsByName("description")[0].content,
"inLanguage":"vi",
"itemReviewed": {
"@type":"Product",
"name": "<data:blog.pageName/>",
"description":"" + document.getElementsByName("description")[0].content,
"sameAs": "<data:blog.canonicalUrl/>",
"image": "<data:blog.postImageThumbnailUrl/>",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "5",
"bestRating": "5",
"ratingCount": "20"
}
}
});
});
//]]>
</script>
我想请人看看我在上面的 javascript 代码中是否做错了什么?如果是这样,为什么谷歌不识别这个 json-ld 数据?
提前致谢!
解决方案
推荐阅读
- python - 伙计们,我们如何将 Tacotron 添加到 python 程序中,我制作了一个 AI 程序,我希望它有 Tacotron VCTK p240 的声音
- python - 基于当前日期的 Flask 名称记录文件
- r - 如何使用分类坐标微调 geom_segment
- python-3.x - 使用 Python 的 Systemtap
- matplotlib - xtick 标签未显示在 matplotlib 中
- javascript - Node/Express:通过 SELECT 语句从 postgres 中获取值
- c# - AutoMapper 未映射 IEnumerable 问题
- networking - 无法从网络中的计算机访问 mayan-edms
- javascript - 使用 sinon 存根,但未调用存根
- d3.js - 为什么我的图表的轴在不同的浏览器中移动?