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

gulp-metalsmith

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-metalsmith

Lightweight gulp plugin for Metalsmith

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
223
decreased by-19.2%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-metalsmith

gulp-metalsmith is a gulp plugin that incorporates Metalsmith builds into gulp pipelines. It aims to be as lightweight as possible. It ships with Metalsmith's replacement that has compatible API (can reuse Metalsmith plugins) and is able to recive JavaScript object containing page definitions. After build, it streams out vinyl files. The main difference between bundled Metalsmith and normal Metalsmith is that it does not perform any disc read/write operations, leaving it out to gulp.

gulp-metalsmith can be feed with specially formatted JSON. It allows building static pages using content providers, like prismic.io or Contentful.

Installation

$ npm install --save-dev gulp-metalsmith

Use it with gulp

The simplest build task (just copies all files from src/ to build/):

gulp.task('metalsmith', ['clean'], function() {
    return gulp.src('src/**').
        pipe(metalsmith()).
        pipe(gulp.dest('build'));
});

All options:

s.pipe(metalsmith({
    // set Metalsmith's root directory, for example for locating templates, defaults to CWD
    root: __dirname, 
    // read frontmatter, defaults to true
    frontmatter: true,
    // Metalsmith plugins to use
    use: [ permalinks(), layouts({ engine: 'swig' }) ]
}));

Feed it with JSON

Given the file src/pages.json:

{
  "index.html": {
    "title": "Homepage",
    "layout": "basic.swig",
    "contents": "<p>In euismod eleifend nunc ac pretium...</p>"
  },
  "contact.html": {
    "title": "Contact",
    "layout": "basic.swig",
    "contents": "<p>Lorem ipsum dolor sit amet...</p>"
  }
}

You can do this:

gulp.task('metalsmith-json', ['clean'], function() {
    return gulp.src('src/pages.json').
        pipe(metalsmith({ use: [ layouts({ engine: 'swig' }) ])).
        pipe(gulp.dest('build'));
});

Multiple JSON files (*.json) are also accepted.

Examples, tests

Examples are stored in example/. Tests can be run using tape (you probably just need to type faucet in the project's root directory).

Author

Jakub Elżbieciak

License

MIT

FAQs

Package last updated on 26 Mar 2015

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