Skip to content

Commit

Permalink
feat(package): added structured data support
Browse files Browse the repository at this point in the history
added structured data support, like schema.org using the json-ld
  • Loading branch information
nickfrosty committed Dec 21, 2021
1 parent 849947e commit cfa5e4b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions package/lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default function (ctx, inject) {
ctx.app.head.title = nuxtSeo.createTitle(options)
ctx.app.head.meta = nuxtSeo.createMeta(options, ctx.app.head.meta, template)


if (ctx.route && ctx.route.path) {
ctx.app.head.link = nuxtSeo.createCanonical(options, ctx.route.path)
}
Expand All @@ -26,11 +25,19 @@ export default function (ctx, inject) {
}

if(options.jsonld){

if ( ctx.app.head.script ){
ctx.app.head.script = ctx.app.head.script.filter(( item ) => {
if ( item.vmid && item.vmid != 'ldjson-schema')
return item;
});
}

ctx.app.head.script.push({
vmid: 'ldjson-schema',
json: options.jsonld,
type: 'application/ld+json'
});
});
}

try {
Expand Down

0 comments on commit cfa5e4b

Please # to comment.