adamaveray / gulp-index-dirs

A Gulp plugin to rename non-index files to indices within matching subdirectories.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@averay/gulp-index-dirs

View code coverage on codecov

A Gulp plugin to rename non-index files to indices within matching subdirectories.

This plugin can be used to enable serving a static website with clean, extensionless URLs (e.g. https://www.example.com/example-page/) without needing to configure the web server to rewrite URLs, by moving generated files to index files within a matching subdirectory.

For example, given the following source files:

pages/index.html
pages/about.html
pages/contact.html

The following files will be output:

dist/index.html
dist/about/index.html
dist/contact/index.html

Usage

Import the indexDirs function and add it to a Gulp stream.

import indexDirs from '@averay/gulp-index-dirs';

gulp
  .src('...')
  .pipe(/* Apply plugins */)
  .pipe(indexDirs())
  .pipe(gulp.dest('...'));

Options

The function takes a single optional argument of the extensionless index file name, defaulting to index:

// ...
.pipe(indexDirs('default')) // Will result in e.g. default.html

MIT License

About

A Gulp plugin to rename non-index files to indices within matching subdirectories.

License:MIT License


Languages

Language:TypeScript 88.3%Language:JavaScript 9.9%Language:Shell 1.8%