npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tf-metatags

v2.0.0

Published

Angular module for providing MetaTags support based on routes.

Downloads

77

Readme

tfMetaTags

Codeship Status for thiagofesta/tf-metatags Build Status TravisCI codecov.io coveralls.io bower.io npm Code Climate

Angular module for providing MetaTags support based on routes.

Inspired from angular-metatags and used some ideas from ui-router-metatags.

Versions

When using ui-router 1 or higher, use tf-metatags 2 or higher.

| ui-router | tf-metatags | | --------- | ----------- | | >= 1.0.0 | >= 2.0.0 | | < 1.0.0 | < 2.0.0. |

Installation

Download tf-metatags.min.js and include it on your page

<script src="tf-metatags.min.js"></script>

Include it in your module declaration

angular.module('myApp', ['ui.router', 'tf.metatags']);

Add the tfMetaTags service to your page

<title ng-bind="tfMetaTags.title"></title>
<meta ng-repeat="(key, value) in tfMetaTags.properties" name="{{key}}" content="{{value}}" >

Then configure defaults

angular
  .module('myApp')
  .config(['tfMetaTagsProvider', function (tfMetaTagsProvider) {

    tfMetaTagsProvider.setDefaults({
      title: 'Default Title',
      properties: {
        keywords: 'keyword1, keyword2'
      }
    });

    tfMetaTagsProvider.setTitleSuffix(' | MetaTags');
    tfMetaTagsProvider.setTitlePrefix('Prefix ');

  }]);

And finally decorate the routes with tfMetaTags:

angular
  .module('myApp')
  .config(['$stateProvider', function ($stateProvider, $windowProvider) {

    var $window = $windowProvider.$get();

    $stateProvider
      .state('home', {
        url: '/',
        tfMetaTags: {
          title: 'Home',
          properties: {
            description: 'This is the homepage',
            keywords: 'keyword1, keyword2',
            'og:title': 'Home',
            'og:url': function() {
              return $window.location.href;
            },
            'twitter:title': 'Home'
          }
        }
      })
      .state('movie', {
        url: '/movie',
        resolve: {
          /* @ngInject */
          movieData: function($q, $timeout) {
            var deferred = $q.defer();
  
            $timeout(function() {
              deferred.resolve({
                title: 'The Lord of the Rings: The Fellowship of the Ring',
                year: 2001,
                summary: 'A meek hobbit of the Shire and eight companions set out on a journey to Mount Doom to destroy the One Ring and the dark lord Sauron.'
              });
            }, 1000);
  
            return deferred.promise;
          }
        },
        tfMetaTags: {
          /* @ngInject */
          title: function(movieData) {
            return movieData.title;
          },
          properties: {
            description: 'Summary: {{movieData.summary}}; Year: {{movieData.year}}'
          }
        }
      });

  }]);

SEO concerns

Until the search engine bots will be able to execute javascript properly you will have to use a tool like prerender.io or brombone to serve prerendered pages when a bot visit your site.

You can read more for the topic on the following articles:

-Weluse.de - Angular & SEO finally a piece of cake

-Builtvisible.com - The Basics of JavaScript Framework SEO in AngularJS

-Yearofmoo.com - AngularJS and SEO

Running sample app & Testing

First you need to install the dependencies

npm install
./node_modules/bower/bin/bower install && ./node_modules/protractor/bin/webdriver-manager update

Now you are able to have the server up and running. Go and start the server

grunt server

Running tests

We have JSHint, JSCS, Unit tests and E2E tests.

All of them can be run once using the following command

grunt test

You can see the coverage on the command line output or more details opening the test/coverage/index.html file on your browser.

Running JSHint

For running JSHint

grunt test:jshint
Running JSCS

For running JSCS

grunt test:jscs
Running Unit Tests

For running unit tests

grunt test:unit
Running E2E Tests

For running E2E

grunt test:e2e

Building

For create a build run

grunt build

This task will also make sure all tests are passing before making the build, once build is completed it also perform tests against the generated code.