ng-meta
Advanced tools
Comparing version 0.3.6 to 0.3.7
{ | ||
"name": "ngMeta", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"authors": [ | ||
@@ -5,0 +5,0 @@ "Vinay Gopinath <vinayg18@gmail.com>" |
#Changelog | ||
## [v0.3.7](https://github.com/vinaygopinath/ngMeta/releases/tag/v0.3.7) | ||
##### Features | ||
* Method chaining for ngMeta and ngMetaProvider | ||
```javascript | ||
ngMetaProvider | ||
.setDefaultTag('ogImage', 'http://url.com/picture.jpg') | ||
.setDefaultTag('ogSiteName', 'Site Name') | ||
.useTitleSuffix(true) | ||
.setDefaultTitleSuffix(' - Demcoach'); | ||
``` | ||
* Improved method documentation | ||
## [v0.3.6](https://github.com/vinaygopinath/ngMeta/releases/tag/v0.3.6) | ||
@@ -4,0 +17,0 @@ |
@@ -38,4 +38,4 @@ (function(root, factory) { | ||
/** | ||
* @ngdoc function | ||
* @name setTitle | ||
* @ngdoc method | ||
* @name ngMeta#setTitle | ||
* @description | ||
@@ -56,2 +56,4 @@ * Sets the title of the page, optionally | ||
* ngMeta.setTitle('Page name'); | ||
* | ||
* @returns {Object} self | ||
*/ | ||
@@ -66,7 +68,8 @@ var setTitle = function(title, titleSuffix) { | ||
} | ||
return this; | ||
}; | ||
/** | ||
* @ngdoc function | ||
* @name setTag | ||
* @ngdoc method | ||
* @name ngMeta#setTag | ||
* @description | ||
@@ -79,2 +82,4 @@ * Sets the value of a meta tag, using | ||
* ngMeta.setTag('og:image', 'http://example.com/a.png'); | ||
* | ||
* @returns {Object} self | ||
*/ | ||
@@ -89,6 +94,7 @@ var setTag = function(tag, value) { | ||
$rootScope.ngMeta[tag] = angular.isDefined(value) ? value : defaults[tag]; | ||
return this; | ||
}; | ||
/** | ||
* @ngdoc function | ||
* @ngdoc method | ||
* @name readRouteMeta | ||
@@ -105,2 +111,4 @@ * @description | ||
* that were not utilized while setting the state/route tags. | ||
* | ||
* @returns {Object} self | ||
*/ | ||
@@ -138,4 +146,4 @@ var readRouteMeta = function(meta) { | ||
/** | ||
* @ngdoc function | ||
* @name init | ||
* @ngdoc method | ||
* @name ngMeta#init | ||
* @description | ||
@@ -169,12 +177,56 @@ * Initializes the ngMeta object and sets up | ||
/** | ||
* @ngdoc method | ||
* @name ngMetaProvider#setDefaultTitle | ||
* @param {string} titleStr The default title of the page. If a | ||
* route/state does not define a `title` param in its meta object, this | ||
* value is used instead. | ||
* | ||
* @description | ||
* Sets the default title for all routes that are missing a custom `title` | ||
* property in their meta objects. | ||
* | ||
* @returns {Object} self | ||
*/ | ||
this.setDefaultTitle = function(titleStr) { | ||
defaults.title = titleStr; | ||
return this; | ||
}; | ||
/** | ||
* @ngdoc method | ||
* @name ngMetaProvider#setDefaultTitleSuffix | ||
* @param {string} titleSuffix The default title suffix of the page. If a | ||
* route/state does not define a `titleSuffix` param in its meta object, | ||
* this value is used instead. | ||
* | ||
* @description | ||
* Sets the default title suffix for all routes that are missing a custom | ||
* `titleSuffix` property in their meta objects. | ||
* | ||
* @returns {Object} self | ||
*/ | ||
this.setDefaultTitleSuffix = function(titleSuffix) { | ||
defaults.titleSuffix = titleSuffix; | ||
return this; | ||
}; | ||
/** | ||
* @ngdoc method | ||
* @name ngMetaProvider#setDefaultTag | ||
* @param {string} tag The default tag name. The default tag can be | ||
* overridden by defining a custom property of the same name in the meta | ||
* object of any route. | ||
* | ||
* @param {string} value The value of the tag. | ||
* | ||
* @description | ||
* Sets the default tag for all routes that are missing a custom | ||
* `tag` property in their meta objects. | ||
* | ||
* @returns {Object} self | ||
*/ | ||
this.setDefaultTag = function(tag, value) { | ||
defaults[tag] = value; | ||
return this; | ||
}; | ||
@@ -184,4 +236,16 @@ | ||
/** | ||
* @ngdoc method | ||
* @name ngMetaProvider#useTitleSuffix | ||
* @param {boolean} bool A boolean indicating the use of title suffix. | ||
* Defaults to false. | ||
* | ||
* @description | ||
* Toggles the use of the title suffix throughout the site. | ||
* | ||
* @returns {Object} self | ||
*/ | ||
this.useTitleSuffix = function(bool) { | ||
config.useTitleSuffix = !!bool; | ||
return this; | ||
}; | ||
@@ -188,0 +252,0 @@ |
@@ -1,4 +0,4 @@ | ||
/* ngMeta - v0.3.6 - 16-Mar-2016 | ||
/* ngMeta - v0.3.7 - 24-Mar-2016 | ||
https://github.com/vinaygopinath/ngMeta | ||
*/ | ||
!function(a,b){"function"==typeof define&&define.amd?define(["angular"],b):"object"==typeof exports?module.exports=b(require("angular")):a.returnExports=b(a.angular)}(this,function(a){a.module("ngMeta",[]).provider("ngMeta",function(){"use strict";function b(b){var e=function(e,f){if(!b.ngMeta)throw new Error("Cannot call setTitle when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");b.ngMeta.title=a.isDefined(e)?e:c.title,d.useTitleSuffix&&(b.ngMeta.title+=a.isDefined(f)?f:c.titleSuffix)},f=function(d,e){if(!b.ngMeta)throw new Error("Cannot call setTag when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");if("title"===d||"titleSuffix"===d)throw new Error("Attempt to set '"+d+"' through 'setTag': 'title' and 'titleSuffix' are reserved tag names. Please use 'ngMeta.setTitle' instead");b.ngMeta[d]=a.isDefined(e)?e:c[d]},g=function(b){b=b||{},e(b.title,b.titleSuffix);var d=a.copy(c);delete b.title,delete b.titleSuffix,delete d.title,delete d.titleSuffix;for(var g=Object.keys(b),h=0;h<g.length;h++)d.hasOwnProperty(g[h])&&delete d[g[h]],f(g[h],b[g[h]]);for(var i=Object.keys(d),j=0;j<i.length;j++)f(i[j],d[i[j]])},h=function(b,c){g(a.copy(c.meta))},i=function(){b.ngMeta={},b.$on("$routeChangeSuccess",h),b.$on("$stateChangeSuccess",h)};return{init:i,setTitle:e,setTag:f}}var c={},d={useTitleSuffix:!1};this.setDefaultTitle=function(a){c.title=a},this.setDefaultTitleSuffix=function(a){c.titleSuffix=a},this.setDefaultTag=function(a,b){c[a]=b},this.useTitleSuffix=function(a){d.useTitleSuffix=!!a},this.$get=["$rootScope",function(a){return new b(a)}]})}); | ||
!function(a,b){"function"==typeof define&&define.amd?define(["angular"],b):"object"==typeof exports?module.exports=b(require("angular")):a.returnExports=b(a.angular)}(this,function(a){a.module("ngMeta",[]).provider("ngMeta",function(){"use strict";function b(b){var e=function(e,f){if(!b.ngMeta)throw new Error("Cannot call setTitle when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");return b.ngMeta.title=a.isDefined(e)?e:c.title,d.useTitleSuffix&&(b.ngMeta.title+=a.isDefined(f)?f:c.titleSuffix),this},f=function(d,e){if(!b.ngMeta)throw new Error("Cannot call setTag when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");if("title"===d||"titleSuffix"===d)throw new Error("Attempt to set '"+d+"' through 'setTag': 'title' and 'titleSuffix' are reserved tag names. Please use 'ngMeta.setTitle' instead");return b.ngMeta[d]=a.isDefined(e)?e:c[d],this},g=function(b){b=b||{},e(b.title,b.titleSuffix);var d=a.copy(c);delete b.title,delete b.titleSuffix,delete d.title,delete d.titleSuffix;for(var g=Object.keys(b),h=0;h<g.length;h++)d.hasOwnProperty(g[h])&&delete d[g[h]],f(g[h],b[g[h]]);for(var i=Object.keys(d),j=0;j<i.length;j++)f(i[j],d[i[j]])},h=function(b,c){g(a.copy(c.meta))},i=function(){b.ngMeta={},b.$on("$routeChangeSuccess",h),b.$on("$stateChangeSuccess",h)};return{init:i,setTitle:e,setTag:f}}var c={},d={useTitleSuffix:!1};this.setDefaultTitle=function(a){return c.title=a,this},this.setDefaultTitleSuffix=function(a){return c.titleSuffix=a,this},this.setDefaultTag=function(a,b){return c[a]=b,this},this.useTitleSuffix=function(a){return d.useTitleSuffix=!!a,this},this.$get=["$rootScope",function(a){return new b(a)}]})}); |
{ | ||
"name": "ng-meta", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "Meta tags support for AngularJS single page applications (SPA)", | ||
@@ -5,0 +5,0 @@ "main": "src/ngMeta.js", |
# ngMeta | ||
> Dynamic meta tags in your AngularJS single page application | ||
[![Build Status](https://travis-ci.org/vinaygopinath/ngMeta.svg?branch=master)](https://travis-ci.org/vinaygopinath/ngMeta) | ||
[![npm version](https://badge.fury.io/js/ng-meta.svg)](https://badge.fury.io/js/ng-meta) [![Build Status](https://travis-ci.org/vinaygopinath/ngMeta.svg?branch=master)](https://travis-ci.org/vinaygopinath/ngMeta) | ||
@@ -6,0 +6,0 @@ * [Demo](#demo) |
@@ -38,4 +38,4 @@ (function(root, factory) { | ||
/** | ||
* @ngdoc function | ||
* @name setTitle | ||
* @ngdoc method | ||
* @name ngMeta#setTitle | ||
* @description | ||
@@ -56,2 +56,4 @@ * Sets the title of the page, optionally | ||
* ngMeta.setTitle('Page name'); | ||
* | ||
* @returns {Object} self | ||
*/ | ||
@@ -66,7 +68,8 @@ var setTitle = function(title, titleSuffix) { | ||
} | ||
return this; | ||
}; | ||
/** | ||
* @ngdoc function | ||
* @name setTag | ||
* @ngdoc method | ||
* @name ngMeta#setTag | ||
* @description | ||
@@ -79,2 +82,4 @@ * Sets the value of a meta tag, using | ||
* ngMeta.setTag('og:image', 'http://example.com/a.png'); | ||
* | ||
* @returns {Object} self | ||
*/ | ||
@@ -89,6 +94,7 @@ var setTag = function(tag, value) { | ||
$rootScope.ngMeta[tag] = angular.isDefined(value) ? value : defaults[tag]; | ||
return this; | ||
}; | ||
/** | ||
* @ngdoc function | ||
* @ngdoc method | ||
* @name readRouteMeta | ||
@@ -105,2 +111,4 @@ * @description | ||
* that were not utilized while setting the state/route tags. | ||
* | ||
* @returns {Object} self | ||
*/ | ||
@@ -138,4 +146,4 @@ var readRouteMeta = function(meta) { | ||
/** | ||
* @ngdoc function | ||
* @name init | ||
* @ngdoc method | ||
* @name ngMeta#init | ||
* @description | ||
@@ -169,12 +177,56 @@ * Initializes the ngMeta object and sets up | ||
/** | ||
* @ngdoc method | ||
* @name ngMetaProvider#setDefaultTitle | ||
* @param {string} titleStr The default title of the page. If a | ||
* route/state does not define a `title` param in its meta object, this | ||
* value is used instead. | ||
* | ||
* @description | ||
* Sets the default title for all routes that are missing a custom `title` | ||
* property in their meta objects. | ||
* | ||
* @returns {Object} self | ||
*/ | ||
this.setDefaultTitle = function(titleStr) { | ||
defaults.title = titleStr; | ||
return this; | ||
}; | ||
/** | ||
* @ngdoc method | ||
* @name ngMetaProvider#setDefaultTitleSuffix | ||
* @param {string} titleSuffix The default title suffix of the page. If a | ||
* route/state does not define a `titleSuffix` param in its meta object, | ||
* this value is used instead. | ||
* | ||
* @description | ||
* Sets the default title suffix for all routes that are missing a custom | ||
* `titleSuffix` property in their meta objects. | ||
* | ||
* @returns {Object} self | ||
*/ | ||
this.setDefaultTitleSuffix = function(titleSuffix) { | ||
defaults.titleSuffix = titleSuffix; | ||
return this; | ||
}; | ||
/** | ||
* @ngdoc method | ||
* @name ngMetaProvider#setDefaultTag | ||
* @param {string} tag The default tag name. The default tag can be | ||
* overridden by defining a custom property of the same name in the meta | ||
* object of any route. | ||
* | ||
* @param {string} value The value of the tag. | ||
* | ||
* @description | ||
* Sets the default tag for all routes that are missing a custom | ||
* `tag` property in their meta objects. | ||
* | ||
* @returns {Object} self | ||
*/ | ||
this.setDefaultTag = function(tag, value) { | ||
defaults[tag] = value; | ||
return this; | ||
}; | ||
@@ -184,4 +236,16 @@ | ||
/** | ||
* @ngdoc method | ||
* @name ngMetaProvider#useTitleSuffix | ||
* @param {boolean} bool A boolean indicating the use of title suffix. | ||
* Defaults to false. | ||
* | ||
* @description | ||
* Toggles the use of the title suffix throughout the site. | ||
* | ||
* @returns {Object} self | ||
*/ | ||
this.useTitleSuffix = function(bool) { | ||
config.useTitleSuffix = !!bool; | ||
return this; | ||
}; | ||
@@ -188,0 +252,0 @@ |
40139
14
748