grunt-short-url

1.0.4 • Public • Published

grunt-short-url Build Status

Simple grunt plugin for shortening URLs in HTML files

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-short-url --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-short-url');

The "shorturl" task

This grunt task uses bitly's api for shortening URLs.

Options

bitly

Type: Object

{
  username: 'your username',
  password: 'your password',
  client_id: 'your client id',
  client_secret: 'your client secret'
}

If you know your access token, you can add access_token: 'your access token' and remove the username and password properties.

html

Type: Object
Default:

{
  'a[href]': 'href',
  'img[src]': 'src',
  'link[rel=stylesheet]': 'href',
  'script[src]': 'src'
}

Any HTML element matching these CSS selectors will have their attribute, specified in value, shortened.

Usage Examples

grunt.initConfig({
  shorturl: {
    yourTarget: {
      options:
      {
        bitly: {
          username: 'your username',
          password: 'your password',
          client_id: 'your client id',
          client_secret: 'your client secret'
        },
        html: {
          'a[href]': 'href',
          'img[src]': 'src',
        }
      },
 
      // HTML files
      files:
      [{
        src: 'src/*.html',
        dest: 'dest/'
      }]
    }
  }
});

Package Sidebar

Install

npm i grunt-short-url

Weekly Downloads

1

Version

1.0.4

License

none

Last publish

Collaborators

  • mguillin