New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

metalsmith-slug

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metalsmith-slug - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

31

lib/index.js

@@ -0,1 +1,2 @@

var path = require('path');
var slug = require('slug');

@@ -12,5 +13,21 @@ var minimatch = require('minimatch');

function saveSlug (files, file, property, slugOpts) {
var currFile = files[file];
currFile.slug = slug(currFile[property], slugOpts);
}
function renameKey (files, file) {
var currFile = files[file];
var currPath = path.dirname(file);
var currExt = path.extname(file);
var slugFilename = path.join(currPath, currFile.slug + currExt);
files[slugFilename] = currFile;
delete files[file];
}
function plugin (opts) {
opts = opts || {};
opts.property = opts.property || 'title';
opts.renameFiles = opts.renameFiles || false;

@@ -30,6 +47,12 @@ var slugOpts = {};

matchedFiles.forEach(function (file) {
var currFile = files[file];
currFile.slug = slug(currFile[opts.property], slugOpts);
});
if (opts.renameFiles) {
matchedFiles.forEach(function (file) {
saveSlug(files, file, opts.property, slugOpts);
renameKey(files, file);
});
} else {
matchedFiles.forEach(function (file) {
saveSlug(files, file, opts.property, slugOpts);
});
}

@@ -36,0 +59,0 @@ done();

2

package.json
{
"name": "metalsmith-slug",
"version": "0.0.2",
"version": "0.0.3",
"description": "slugify a property in metalsmith",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -58,2 +58,11 @@ # metalsmith slug

**renameFiles** _boolean_: When set to `true`, will rename the files passed to
metalsmith-slug to the file's new slug property.
```js
metalsmith.use(slug({
renameFiles: true
}));
```
**slug options**: You can additionally use any of the options available to [node-slug](https://github.com/dodo/node-slug#options)

@@ -67,1 +76,2 @@

```
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