Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

metalsmith-bitly

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metalsmith-bitly

A metalsmith plugin for bitly links

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

metalsmith-bitly

npm version

A Metalsmith plugin that adds bitly links to the metadata of each file.

This plugin allows you to retrieve bit.ly short links and use them in your templates. For support questions please use stack overflow or the slack channel.

Installation

$ npm i metalsmith-bitly

Usage

You can use metalsmith-bitly with the with Metalsmith's Javascript API or CLI. You must also set the siteURL value on your site's metadata configuration.

Options

  • accessToken: your personal bitly access token (required)
  • baseURL: your production base URL (semi-required, either this or baseURLGlobalMetadataKey is needed)
  • baseURLGlobalMetadataKey: the global metaday key of your production base URL (semi-required, either this or baseURL is needed)
  • brandedShortDomain: an override for the default domain (optional, defaults to bit.ly)
  • pathMetadataKey: an override for the default file path (optional, defaults to path)
accessToken

In order to utilize this plugin you must request an access token at bit.ly's developer site. Please remember to exclude your bitly authorization key if your repository is public. You can use the below example and include your private configuration file in your repository's .gitignore file.

const bitly = require('metalsmith-bitly');
const configPrivate = require('../configPrivate');
const Metalsmith = require('metalsmith');

return Metalsmith(__dirname)
  .use(bitly({
    accessToken: configPrivate.bitlyToken,
    baseURL: 'http://welchcanavan.com/'
  }))
  .build(function(err) {
    if (err) throw err;
});
baseURL

A semi-required value, you must specify either this or baseURLGlobalMetadataKey. This is the base URL that will be combined with your file's path to sent to bit.ly.

const bitly = require('metalsmith-bitly');
const configPrivate = require('../configPrivate');
const Metalsmith = require('metalsmith');

return Metalsmith(__dirname)
  .use(bitly({
    accessToken: configPrivate.bitlyToken,
    baseURL: 'http://welchcanavan.com/'
  }))
  .build(function(err) {
    if (err) throw err;
});
baseURLGlobalMetadataKey

A semi-required value, you must specify either this or baseURL. Use this if you'd like to make sure this plugin stays in sync with a globally used or required metadate value for your site's production base URL.

const bitly = require('metalsmith-bitly');
const configPrivate = require('../configPrivate');
const Metalsmith = require('metalsmith');

return Metalsmith(__dirname)
  .metadata({
    siteURL: 'http://welchcanavan.com/',
  })
  .use(bitly({
    accessToken: configPrivate.bitlyToken,
    baseURLGlobalMetadataKey: siteURL
  }))
  .build(function(err) {
    if (err) throw err;
});
brandedShortDomain

Specify this value if you have set up a Branded Short Domain with bit.ly.

const bitly = require('metalsmith-bitly');
const configPrivate = require('../configPrivate');
const Metalsmith = require('metalsmith');

return Metalsmith(__dirname)
  .use(bitly({
    accessToken: configPrivate.bitlyToken,
    baseURL: 'http://welchcanavan.com/',
    brandedShortDomain: 'http://xiw.cx/'
  }))
  .build(function(err) {
    if (err) throw err;
});
pathMetadataKey

To be used in concert with the metalsmith-permalinks plugin. You can specify a file metadata key to match a pattern used in the permalinks plugin. Order is important here, you have to run metalsmith-bitly after metalsmith-permalinks or the paths won't match.

---
title: A Post About A Thing
slug: post-thing
---
const bitly = require('metalsmith-bitly');
const collections = require('metalsmith-collections');
const configPrivate = require('../configPrivate');
const Metalsmith = require('metalsmith');
const permalinks  = require('metalsmith-permalinks');

return Metalsmith(__dirname)
  .use(collections({
    posts: {
      pattern: 'posts/*.md',
      sortBy: 'date',
      reverse: true
    }
  }))
  .use(permalinks({
    linksets: [
      {
        match: { collection: 'posts' },
        pattern: ':slug'
      }
    ]})
  )
  .use(bitly({
    accessToken: configPrivate.bitlyToken,
    pathMetadataKey: 'slug'
  }))
  .build(function(err) {
    if (err) throw err;
});

Note: I've thought about including an option to focus this plugin on a collection or list of collections. If that would be of interest to you, feel free to leave a note or a pull request.

License

MIT

Keywords

FAQs

Package last updated on 27 Sep 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc