Skip to content

Commit

Permalink
doc(#513): Update eleventy-plugin documentation to have options
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-wade committed Dec 5, 2023
1 parent 712543f commit 4c60f2d
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions packages/website/pages/eleventy-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,25 @@ const tybaltPlugin = require('@tybalt/eleventy-plugin');

module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(tybaltPlugin, {
components: ['./components'],
pattern: './components',
outfile: 'tybalt-out.js'
});
};
```

## Usage

The plugin makes the components available for use on all of your pages. If you have a component defined like this
The plugin makes your component library available for use on all of your pages. If you have a component defined like this

```javascript
defineComponent({
name: 'FooBarBaz',
props: {
value: {},
},
render({ value }) {
return html`got value: ${value}`;
})
});
```

Expand All @@ -49,3 +53,55 @@ You can use it on your index.html or page.md like any other html element
```html
<foo-bar-baz value="value"></foo-bar-baz>
```

## Options

The plugin takes a pair of options to configure its usage

### outfile

This is the name of the file the plugin will generate that contains your component library. It defaults to `tybalt-out.js`, but you can configure it to be any valid filename. For instance, if you set this option as follows

```javascript
const tybaltPlugin = require('@tybalt/eleventy-plugin');

module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(tybaltPlugin, {
outfile: 'index.js'
});
};
```

The generated view will include a script tag as follows

```html
<script src="/index.js"></script></body></html>
```

And the file loaded by the browser and generated by the build will be called `index.js`, rather than `tybalt-out.js`.

### pattern

This is the pattern for the component definitions that will be included in your component library. Defaults to `./components`, which corresponds to a file tree as follows

```shell
└── components
   ├── component-one.js
   ├── component-two.js
   └── component-three.js
```

where each component is a single file. If you'd prefer to have multiple files in a single directory, you could set this to `./components/**/*.component.ts`, to treat all files ending in `.component.ts` as entry points, which corresponds to a file tree as follows

```shell
├── components
│   ├── ComponentOne
│   │   ├── one.component.ts
│   │   ├── one.test.ts
│   │   └── one.css
│   ├── ComponentTwo
│   │   └── two.ts
│   └── ComponentThree
│      ├── header.ts
│      └── header.css
```

0 comments on commit 4c60f2d

Please sign in to comment.