metalsmith-slug
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1,5 +0,3 @@ | ||
var slug = require('slug'); | ||
var slug = require('slug'); | ||
var minimatch = require('minimatch'); | ||
var join = require('path').join; | ||
var isMatch = false; | ||
@@ -24,4 +22,5 @@ module.exports = plugin; | ||
return function (files, metalsmith, done) { | ||
var dest = metalsmith.destination(); | ||
var src = metalsmith.source(); | ||
opts.patterns = opts.patterns || [src + '/**']; | ||
var matchedFiles = Object.keys(files).filter(function (file) { | ||
@@ -40,4 +39,1 @@ return matchGlobArray(file, opts.patterns); | ||
function absPath (relative) { | ||
return join(process.cwd(), relative); | ||
} |
{ | ||
"name": "metalsmith-slug", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "slugify a property in metalsmith", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -5,2 +5,62 @@ # metalsmith slug | ||
[Metalsmith](http://www.metalsmith.io/), based on a particular property. | ||
Useful for generating links to pages. | ||
Useful for generating links to pages based on, say, their title. | ||
## Installation | ||
npm install metalsmith-slug | ||
## Usage | ||
If you're not familiar with Metalsmith, check it out. It's a very versatile file | ||
processor that can be used for static site generation, project scaffolding and | ||
more. | ||
### Metalsmith CLI | ||
Add `metalsmith-slug` to your `metalsmith.json`. | ||
```json | ||
{ | ||
"plugins": { | ||
"metalsmith-slug": {} | ||
} | ||
} | ||
``` | ||
### Metalsmith JavaScript API | ||
Add `metalsmith-slug` to your project and `.use()` it. | ||
```js | ||
var slug = require('metalsmith-slug'); | ||
metalsmith.use(slug()); | ||
``` | ||
## Options | ||
**patterns** _[array]_: Glob patters of files to match. Uses | ||
[minimatch](https://github.com/isaacs/minimatch). | ||
```js | ||
metalsmith.use(slug({ | ||
patterns: ['*.md', '*.rst'] // Deafults to metalsmith.source() directory | ||
})); | ||
``` | ||
**property** _'string'_: Property to generate the slug from. | ||
```js | ||
metalsmith.use(slug({ | ||
property: 'name' // Defaults to 'title' | ||
})); | ||
``` | ||
**slug options**: You can additionally use any of the options available to [node-slug](https://github.com/dodo/node-slug#options) | ||
```js | ||
metalsmith.use(slug({ | ||
replacement: '_', // Defaults to node-slug defaults | ||
symbols: false | ||
})); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2902
66
28