Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sposhe/component-indexer
https://github.com/sposhe/component-indexer
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sposhe/component-indexer
- Owner: sposhe
- Created: 2020-07-03T18:36:42.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-29T01:55:15.000Z (over 4 years ago)
- Last Synced: 2024-11-07T10:55:05.280Z (about 2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# component-indexer
Node module. Creates an `_index` file in a specified directory that references all of the files in that directory. This is useful for bulk importing SCSS modules or Pug mixins. Contains presets for SCSS and Pug, or options can be specified manually.
## Usage
Given this file structure—
```
.
└── src
└── pug
└── mixins
├── _blockquote.pug
├── _section.pug
└── _card.pug
``````js
const componentIndexer = require('component-indexer')
componentIndexer('src/pug/mixins', 'pug')
```
—the above will create `./src/pug/mixins/_index.pug` with this content:```pug
include _blockquote
include _card
include _section
```## Syntax
```js
componentIndexer(path, filetype [,{prefix, suffix, extension}])
```### Options
* `path` (String) Relative path to the directory to be indexed
* `filetype`: (String) Extension of the files to be indexed
* `prefix`: (String, optional) Prepended before each file name in the index file
* `suffix`: (String, optional) Appended after each file name in the index file
* `extension`: (Boolean, optional) Include extension of each file in the index file## Presets
If the `filetype` matches one of the presets, the values of `prefix`, `suffix`, and `extension` will use the preset values by default.
```js
presets: {
pug: { prefix: `include `, suffix: ``, extension: false },
scss: { prefix: `@import '`, suffix: `';`, extension: false },
}
```