简体   繁体   中英

JSON-LD Schema NUXT

I am creating a Nuxt application powered by Wordpress.

I am receiving JSON-LD in my WP REST API via a schema plugin.Like so,

{
  wp_post_schema: "{"@context":"https://schema.org"}"
}

Below is how I use it in 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
      };
    } 
  }

My problem is that the JSON-LD rendered on the page is sanitized and is not recognised by google markup tool. Any suggestion on how i can effectively implement schema markup?

You should use a v-html to show the content more sanitize.

<template>
  <script v-html="POST", type="application/ld+json">
</template>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM