Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc(#513): Update eleventy-plugin documentation to have options #522

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
```