Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
ui-router-metatags
Advanced tools
Metatags support for the AngularUI Router
Heavily inspired by tf-metatags and angular-ui-router-title.
Google updated they crawler to execute javascript, so if you use this component then your pages will be indexed by google. However, other crawlers - search engines or social services like facebook - still need to see the page after being rendered by javascript. Therefor it is still recommended to use a service like prerender.io
$ npm install ui-router-metatags
or
$ bower install ui-router-metatags
See the sample app for a complete example, otherwise, read below
Include the script in your index file
<script src="node_modules/ui-router-metatags/dist/ui-router-metatags.min.js"></script>
Include it in your module declaration and in your run block
angular.module('myApp', ['ui.router', 'ui.router.metatags']);
function runBlock($rootScope, MetaTags) {
$rootScope.MetaTags = MetaTags;
}
angular
.module('myApp')
.run(['$rootScope', 'MetaTags', runBlock]);
Add the tags to your index file
<title ng-bind="MetaTags.title">Default title</title>
<meta name="description" content="{{MetaTags.description}}">
<meta name="keywords" content="{{MetaTags.keywords}}">
<meta ng-repeat="(key, value) in MetaTags.properties" property="{{key}}" content="{{value}}" >
<meta name="prerender-status-code" content="{{MetaTags.prerender.statusCode}}">
<meta name="prerender-header" ng-if="MetaTags.prerender.header" content="{{MetaTags.prerender.header}}">
Then configure defaults
function configure(UIRouterMetatagsProvider) {
UIRouterMetatagsProvider
.setTitlePrefix('prefix - ')
.setTitleSuffix(' | MyApp')
.setDefaultTitle('MyApp')
.setDefaultDescription('description')
.setDefaultKeywords('keywords')
.setStaticProperties({
'fb:app_id': 'your fb app id',
'og:site_name': 'your site name'
})
.setOGURL(true);
}
angular
.module('myApp')
.config(['UIRouterMetatagsProvider', configure]);
(Static properties are added to all pages and the "setOGURL" method ensures that a 'og:url' property is added to all pages.)
And finally decorate the routes with metatags in the route configs like so:
function configureRoutes($stateProvider) {
$stateProvider
.state('frontpage', {
url: '/',
metaTags: {
title: 'Frontpage',
description: 'This is the frontpage',
keywords: 'lots of interresting keywords',
properties: {
'og:title': 'Frontpage'
}
}
})
.state('blogposts', {
url: '/blog/:category',
resolve: {
/* @ngInject */
posts: function(myService, $stateParams) {
return myService.getPosts($stateParams.category);
}
},
metaTags: {
prerender: {
/* @ngInject */
statusCode: function(posts) {
return posts.length > 0 ? 200 : 302;
},
/* @ngInject */
header: function(posts) {
return posts.length > 0 ? null : 'Location: http://example.com/posts';
}
}
}
})
.state('blogpost', {
url: '/post/:id',
resolve: {
/* @ngInject */
blogpost: function(myService, $stateParams) {
return myService.getPost($stateParams.id);
}
},
metaTags: {
/* @ngInject */
title: function(blogpost) {
return blogpost.title;
},
description: 'The most interresting post {{blogpost.title}}'
}
});
}
angular
.module('myApp')
.config(['$stateProvider', configureRoutes]);
Note that all tags can be either a simple string, a resolve function or a interpolated string (where the properties available are the ones you resolve in your route).
Please note that any routes without metatags will cause a debug log statement, so remember to disable debug logging in production. Example of such a log statement:
MetaTags - route: "app.dashboard" does not contain any metatags
Install nodejs and the following packages globally:
then run:
Then finally, run "gulp"
FAQs
Metatags support for the AngularUI Router
The npm package ui-router-metatags receives a total of 101 weekly downloads. As such, ui-router-metatags popularity was classified as not popular.
We found that ui-router-metatags demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.