Code Monkey home page Code Monkey logo

gulp-url-builder's Introduction

gulp-url-builder

A simple gulp-rename wrapper to generate static urls from a flat file structure. Built for use with gulp-pug, allows a flat set of files to be easily expanded into directories based on a simple naming convention. Can be used with any type of file, and does not affect the file extension.

Installation

npm install gulp-url-builder --save-dev

Naming

The package automatically outputs every file as an index.* file inside a directory with the original file's name. Parent directories can be created by prepending parent directory names delimited by underscores. Files already named index.* are output as-is.

Input Output
index.foo index.foo
about.foo about/index.foo
portfolio_project-a.foo portfolio/project-a/index.foo

Example

const gulp = require('gulp')
const pug = require('gulp-pug')
const urlBuilder = require('gulp-url-builder')

gulp.task('pug', () => {
  return gulp.src([
    'src/pug/views/**/*.pug'
  ]).pipe( pug() )
    .pipe( urlBuilder() )
    .pipe( gulp.dest('dest') )
})

Given the following files in src/pug/views

  .
  ├── index.pug
  ├── about.pug
  ├── about_our-team.pug
  ├── about_our-mission.pug
  ├── about_our-values.pug
  └── contact.pug

—the output in dest would be:

  .
  ├── index.html
  ├── about
  │   ├── index.html
  │   ├── our-team
  │   │   └── index.html
  │   ├── our-mission
  │   │   └── index.html
  │   └── our-values
  │       └── index.html
  └── contact
      └── index.html

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.