我在下一个js中有一个Layout,并且我使用Head组件。 我想使用架构json,但出现错误。
这是我的代码:
<Head>
<script type="application/ld+json">
{{
"@context": "http://schema.org",
"@type": "Person",
address: {
"@type": "PostalAddress",
addressLocality: "Seattle",
addressRegion: "WA",
postalCode: "98052",
streetAddress: "20341 Whitworth Institute 405 N. Whitworth"
},
colleague: [
"http://www.xyz.edu/students/alicejones.html",
"http://www.xyz.edu/students/bobsmith.html"
],
email: "mailto:jane-doe@xyz.edu",
image: "janedoe.jpg",
jobTitle: "Professor",
name: "Jane Doe",
telephone: "(425) 123-4567",
url: "http://www.janedoe.com"
}}
</script>
</Head>
这是我的错误:
Objects are not valid as a React child (found: object with keys {@context, @type, address, colleague, email, image, jobTitle, name, telephone, url}).
If you meant to render a collection of children, use an array instead. in script (at Layout.js:130) in head in Head (at _document.js:43) in html in Html (at _document.js:42) in MyDocument in Context.Provider in Context.Provider
请帮助!
答案 0 :(得分:1)
基于您提供的示例结构化数据片段。这应该可以解决您的问题。
但是,如果您打算在 google's rich result testing tool 上测试您的结构化数据片段,则需要使用通用脚本标记,将键放在双引号中并排除危险的SetInnerHTML 属性。
<Head>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify({
"@context": "http://schema.org",
"@type": "Person",
address: {
"@type": "PostalAddress",
addressLocality: "Seattle",
addressRegion: "WA",
postalCode: "98052",
streetAddress: "20341 Whitworth Institute 405 N. Whitworth"
},
colleague: [
"http://www.xyz.edu/students/alicejones.html",
"http://www.xyz.edu/students/bobsmith.html"
],
email: "mailto:jane-doe@xyz.edu",
image: "janedoe.jpg",
jobTitle: "Professor",
name: "Jane Doe",
telephone: "(425) 123-4567",
url: "http://www.janedoe.com"
})
}}
/>
</Head>
答案 1 :(得分:0)
您需要使用ctx = ssl.create_default_context()
ctx.load_verify_locations(cafile='subca.pem') # contains only sub-CA
ctx.verify_flags |= 0x80000 # set X509_V_FLAG_PARTIAL_CHAIN
ctx.ssl_wrap(...)
来放置架构数据。
dangerouslySetInnerHTML