Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sposhe/gulp-url-builder
https://github.com/sposhe/gulp-url-builder
gulp gulp-plugin gulp-pug gulp-rename static-site
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/sposhe/gulp-url-builder
- Owner: sposhe
- License: mit
- Created: 2020-04-11T19:52:48.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-04-12T14:47:43.000Z (over 4 years ago)
- Last Synced: 2024-11-21T09:02:25.307Z (about 1 month ago)
- Topics: gulp, gulp-plugin, gulp-pug, gulp-rename, static-site
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-url-builder
A simple [`gulp-rename`](https://github.com/hparra/gulp-rename) wrapper to generate static urls from a flat file structure. Built for use with [`gulp-pug`](https://github.com/gulp-community/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
```javascript
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
```