@netsells/nuxt-meta-builder
Advanced tools
Comparing version 2.0.0 to 3.0.0
@@ -8,2 +8,6 @@ "use strict"; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -34,2 +38,3 @@ | ||
* @param {String} val | ||
* @param {Object} options | ||
* | ||
@@ -43,3 +48,7 @@ * @return {Meta} | ||
value: function setDescription(val) { | ||
this.addMeta(['description', 'og:description'], this.limitLetters(val)); | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
options = _objectSpread({ | ||
limit: false | ||
}, options); | ||
this.addMeta(['description', 'og:description'], options.limit ? this.limitLetters(val, options.limit) : val); | ||
return this; | ||
@@ -78,3 +87,3 @@ } | ||
* @param {String} val | ||
* @param {Boolean} raw | ||
* @param {Object} options | ||
* | ||
@@ -87,4 +96,7 @@ * @return {Meta} | ||
value: function setTitle(val) { | ||
var raw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var title = raw ? val : this.limitWords(val); | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
options = _objectSpread({ | ||
limit: false | ||
}, options); | ||
var title = options.limit ? this.limitWords(val, options.limit) : val; | ||
this.title = title; | ||
@@ -91,0 +103,0 @@ this.addMeta(['title', 'og:title'], title); |
@@ -17,10 +17,16 @@ /** | ||
* @param {String} val | ||
* @param {Object} options | ||
* | ||
* @return {Meta} | ||
*/ | ||
setDescription(val) { | ||
setDescription(val, options = {}) { | ||
options = { | ||
limit: false, | ||
...options, | ||
}; | ||
this.addMeta([ | ||
'description', | ||
'og:description', | ||
], this.limitLetters(val)); | ||
], options.limit ? this.limitLetters(val, options.limit) : val); | ||
@@ -58,11 +64,16 @@ return this; | ||
* @param {String} val | ||
* @param {Boolean} raw | ||
* @param {Object} options | ||
* | ||
* @return {Meta} | ||
*/ | ||
setTitle(val, raw = false) { | ||
const title = raw | ||
? val | ||
: this.limitWords(val); | ||
setTitle(val, options = {}) { | ||
options = { | ||
limit: false, | ||
...options, | ||
}; | ||
const title = options.limit | ||
? this.limitWords(val, options.limit) | ||
: val; | ||
this.title = title; | ||
@@ -69,0 +80,0 @@ |
{ | ||
"name": "@netsells/nuxt-meta-builder", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "meta builder class so that you can build the meta object up in a more fluent way", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/netsells/nuxt-meta-builder", |
@@ -53,3 +53,3 @@ # Nuxt Meta Builder | ||
| `setTitle` | Set both the `title` and the `og:title` meta data | `hid` - the title to set<br><br> `content` [optional, default = false] - the title value to set | | ||
| `addMeta` | Set specific meta values | `hid` [required] - the unique meta tag id to set. Can be an single `string` or an `array` of `string`s<br><br>`content` [required] - the meta value to set | | ||
| `addMeta` | Set specific meta values | `hid` [required] - the unique meta tag id to set. Can be a single `string` or an `array` of `string`s<br><br>`content` [required] - the meta value to set | | ||
| `make` | Generate the resulting object | None. | | ||
@@ -56,0 +56,0 @@ |
15632
327