我正在创建由Wordpress驱动的Nuxt应用程序。
我正在通过架构插件在WP REST API中接收JSON-LD。
{
wp_post_schema: "{"@context":"https://schema.org"}"
}
以下是我在NUXT中使用它的方式
head(){
return {
title: 'This is my page title',
meta: [
{ hid: 'description', name: 'description', content: 'This is my description' }
],
script: [
{
json: this.POST.wp_post_schema
type: 'application/ld+json'
}
],
}
},
async asyncData({ $axios, req, params, query, error, route }) {
var POST;
try {
let response = await $axios.get( "https://www.example.com/api);
return {
POST: response.data[0].post_meta_fields
};
}
}
我的问题是页面上呈现的JSON-LD已被清理,Google标记工具无法识别。 关于如何有效实现架构标记的任何建议?
You should use a v-html to show the content more sanitize.