nuxt-jsonld
Advanced tools
Comparing version 1.4.3 to 1.4.4
@@ -0,1 +1,15 @@ | ||
## [1.4.4](https://github.com/ymmooot/nuxt-jsonld/compare/v1.4.3...v1.4.4) (2019-09-23) | ||
### Bug Fixes | ||
* only inject metainfo into correct components ([5c08259](https://github.com/ymmooot/nuxt-jsonld/commit/5c08259)) | ||
* removed dependency and hashing, removed spread in reduce ([5880435](https://github.com/ymmooot/nuxt-jsonld/commit/5880435)) | ||
* restored hash and associated tests ([e79db81](https://github.com/ymmooot/nuxt-jsonld/commit/e79db81)) | ||
### Performance Improvements | ||
* refactored head to use computed ([d7f7785](https://github.com/ymmooot/nuxt-jsonld/commit/d7f7785)) | ||
## [1.4.3](https://github.com/ymmooot/nuxt-jsonld/compare/v1.4.2...v1.4.3) (2019-09-06) | ||
@@ -2,0 +16,0 @@ |
interface Options { | ||
space?: number | string; | ||
} | ||
interface JsonldConfig { | ||
script?: { | ||
hid: string; | ||
type: string; | ||
innerHTML: string; | ||
}[]; | ||
__dangerouslyDisableSanitizersByTagID?: { | ||
[key: string]: ['innerHTML']; | ||
}; | ||
} | ||
interface JsonldMixin { | ||
head: () => JsonldConfig; | ||
beforeCreate: () => void; | ||
} | ||
declare const _default: (options?: Options) => JsonldMixin; | ||
export default _default; |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var xxhashjs_1 = __importDefault(require("xxhashjs")); | ||
var mergeHead_1 = __importDefault(require("./mergeHead")); | ||
exports.default = (function (options) { | ||
@@ -23,28 +23,8 @@ if (options === void 0) { options = {}; } | ||
return { | ||
head: function () { | ||
var _a; | ||
if (!this.$options || typeof this.$options.jsonld !== 'function') { | ||
return {}; | ||
beforeCreate: function () { | ||
if (this.$options && typeof this.$options.jsonld === 'function') { | ||
this.$options.head = mergeHead_1.default.call(this, mergedOptions); | ||
} | ||
if (this.$options.jsonld.call(this) === null) { | ||
return {}; | ||
} | ||
var stringifiedJson = JSON.stringify(this.$options.jsonld.call(this), null, mergedOptions.space); | ||
var innerHTML = mergedOptions.space === 0 ? stringifiedJson : "\n" + stringifiedJson + "\n"; | ||
var hash = xxhashjs_1.default.h32(innerHTML, 0).toString(16); | ||
var hid = "nuxt-jsonld-" + hash; | ||
return { | ||
script: [ | ||
{ | ||
hid: hid, | ||
type: 'application/ld+json', | ||
innerHTML: innerHTML, | ||
}, | ||
], | ||
__dangerouslyDisableSanitizersByTagID: (_a = {}, | ||
_a[hid] = ['innerHTML'], | ||
_a), | ||
}; | ||
}, | ||
}; | ||
}); |
@@ -1,14 +0,15 @@ | ||
import VueT, { ComponentOptions } from 'vue'; | ||
import VueT from 'vue'; | ||
import { MetaInfo } from 'vue-meta'; | ||
declare module 'vue/types/options' { | ||
interface ComponentOptions<V extends VueT> { | ||
jsonld?: () => object; | ||
head?: MetaInfo | (() => MetaInfo); | ||
} | ||
} | ||
export declare const Jsonld: (target: { | ||
options?: ComponentOptions<VueT, import("vue/types/options").DefaultData<VueT>, import("vue/types/options").DefaultMethods<VueT>, import("vue/types/options").DefaultComputed, import("vue/types/options").PropsDefinition<Record<string, any>>, Record<string, any>>; | ||
options?: import("vue").ComponentOptions<VueT, import("vue/types/options").DefaultData<VueT>, import("vue/types/options").DefaultMethods<VueT>, import("vue/types/options").DefaultComputed, import("vue/types/options").PropsDefinition<Record<string, any>>, Record<string, any>>; | ||
} & import("vue").VueConstructor<VueT>) => void; | ||
declare const _default: { | ||
mergeStrategy: (parent: any, child: any, vm: any) => any; | ||
install(Vue: any, options: any): void; | ||
}; | ||
export default _default; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -26,32 +8,7 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var decorator_1 = __importDefault(require("./decorator")); | ||
var mergeStrategy = function (parent, child, vm) { | ||
if (vm) { | ||
return child; | ||
} | ||
return function head() { | ||
var p = typeof parent === 'function' ? parent.call(this) : parent; | ||
var c = typeof child === 'function' ? child.call(this) : child; | ||
if (!p) { | ||
return c; | ||
} | ||
if (!c) { | ||
return p; | ||
} | ||
if (c.script || p.script) { | ||
c.script = __spreadArrays((c.script || []), (p.script || [])); | ||
} | ||
if (c.__dangerouslyDisableSanitizersByTagID || p.__dangerouslyDisableSanitizersByTagID) { | ||
c.__dangerouslyDisableSanitizersByTagID = __assign(__assign({}, (c.__dangerouslyDisableSanitizersByTagID || {})), (p.__dangerouslyDisableSanitizersByTagID || {})); | ||
} | ||
return c; | ||
}; | ||
}; | ||
exports.Jsonld = decorator_1.default; | ||
exports.default = { | ||
mergeStrategy: mergeStrategy, | ||
install: function (Vue, options) { | ||
// eslint-disable-next-line no-param-reassign | ||
Vue.config.optionMergeStrategies.head = mergeStrategy; | ||
Vue.mixin(createMixin_1.default(options)); | ||
}, | ||
}; |
{ | ||
"name": "nuxt-jsonld", | ||
"version": "1.4.3", | ||
"version": "1.4.4", | ||
"description": "manage jsonld in Vue component.", | ||
@@ -60,3 +60,4 @@ "main": "lib/index.js", | ||
"vue": "^2.6.10", | ||
"vue-class-component": "^7.1.0" | ||
"vue-class-component": "^7.1.0", | ||
"vue-meta": "^2.2.2" | ||
}, | ||
@@ -63,0 +64,0 @@ "config": { |
14436
12
26
148