Giter Site home page Giter Site logo

gulp-pagemaki's Introduction

gulp-pagemaki

Gulp plugin to pipe vinyl file objects and transform them into static HTML pages

Usage

var maki = require("gulp-pagemaki");
var path = require("path");

gulp.task('statics', function () {
	
	return gulp.src("./src/pages/**/*.html")
		.pipe(maki({
			templateDir: path.join(__dirname, "src", "layouts")
		}))
		.pipe(gulp.dest("./public"));

});

This takes a folder structure that looks like this:

gulpfile.js
node_modules/
package.json
public/
src/
	js/
	layouts/
		default.html
	pages/
		about/
			index.html
		index.html
	sass/

And will take all of the .html files in src/pages, run them them through the pagemaki parser to find Yaml metadata similar to Jekyll, then use that to find which layout to load from your layout directory that you passed in the gulpfile above.

Once it finds the layout, it drops the content part of each file into the <%= content %> tag in the layout and makes the rest of the variables available to that layout as js vars.

When the parsing and compiling is done, it writes each file, in its preserved folder structure, to the public folder. Now you're building your static HTML files with gulp just like your sass, browserified scripts, etc.

Sample files

src/pages/index.html

---
layout: default
title: My Homepage
---
# Hello from my homepage

src/layouts/default.html

<html>
  <head>
    <title><%= page.title %></title>
  </head>
  <body>
  	<%= content %>
	</body>
</html>

After gulp statics runs...

public/index.html

<html>
  <head>
    <title>My Homepage</title>
  </head>
  <body>
  	<h1>Hello from my homepage</h1>
	</body>
</html>

gulp-pagemaki's People

Contributors

jasonrhodes avatar

Stargazers

Kenta Mori avatar Alexander Mescheryakov avatar

Watchers

James Cloos avatar

Forkers

mksby

gulp-pagemaki's Issues

underscore not found

When I run gulp from the folder where pagemaki lives, it throws an error:

Error: Cannot find module 'underscore' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/Users/natalia/Documents/programming/email-templates/new-professionals/node_modules/gulp-pagemaki/node_modules/pagemaki/pagemaki.js:3:9) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17)

I fixed it this way: changed gulp-pagemaki/node_modules/pagemaki/package.json so dependencies would include "underscore": "~1.7.0".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.