Skip to content
This repository was archived by the owner on Feb 21, 2024. It is now read-only.

Commit c636fab

Browse files
authored
Initial commit
0 parents  commit c636fab

File tree

7 files changed

+176
-0
lines changed

7 files changed

+176
-0
lines changed

.eleventy.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Example use for the demo plugin:
2+
// {{ 'Steph' | hello | safe }}
3+
4+
module.exports = (eleventyConfig, options) => {
5+
// Define defaults for your plugin config
6+
const defaults = {
7+
htmlTag: "h2",
8+
};
9+
10+
// You can create more than filters as a plugin, but here's an example
11+
eleventyConfig.addFilter("hello", (name) => {
12+
// Combine defaults with user defined options
13+
const { htmlTag } = {
14+
...defaults,
15+
...options,
16+
};
17+
18+
return `<${htmlTag}>Hello, ${name}!</${htmlTag}>`;
19+
});
20+
};

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
_site

.npmignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
index.md
2+
_includes
3+
_site

README.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
## Eleventy Plugin Template
2+
3+
> A starter environment for creating plugins for Eleventy (11ty).
4+
5+
Fork this repo, or select "Use this template" to get started.
6+
7+
### Using this template
8+
9+
This template is setup to run a single page 11ty site for testing your plugin functionality. The build files are excluded from the final plugin package via `.npmignore`.
10+
11+
Your plugin functionality should live in/be exported from `.eleventy.js`. You will find a sample of creating a filter plugin in this template, including setting up a default config and merging user options.
12+
13+
**Be sure to update the `package.json` with your own details!**
14+
15+
### Testing your plugin
16+
17+
You can test your functionality within this project's local 11ty build by running `npm start`, but you'll also want to test it _as a plugin_.
18+
19+
From another local 11ty project, you can set the `require()` path relatively to your plugin's project directory, and then use it just as you would for a plugin coming from a package.
20+
21+
Example, assuming you place all your repositories within the same parent directory:
22+
23+
```js
24+
const pluginName = require("../plugin-directory");
25+
26+
module.exports = (eleventyConfig) => {
27+
eleventyConfig.addPlugin(pluginName, { optionName: 'if needed' );
28+
};
29+
```
30+
31+
Then, run the project to test the plugin's functionality.
32+
33+
Note that making changes in the plugin source will likely require restarting the test project.
34+
35+
### Resources for creating an 11ty plugin
36+
37+
- Bryan Robinson's ["Create a Plugin with 11ty"](https://www.youtube.com/watch?v=aO-NFFKjnnE) demonstration on "Learn With Jason"
38+
39+
---
40+
41+
**The following is a boilerplate for your final plugin README**.
42+
43+
## Usage
44+
45+
Describe how to install your plugin, such as:
46+
47+
```bash
48+
npm install @scope/plugin-name
49+
```
50+
51+
Then, include it in your `.eleventy.js` config file:
52+
53+
```js
54+
const pluginName = require("@scope/plugin-name");
55+
56+
module.exports = (eleventyConfig) => {
57+
eleventyConfig.addPlugin(pluginName);
58+
};
59+
```
60+
61+
## Config Options
62+
63+
| Option | Type | Default |
64+
| ----------- | ---- | ------------- |
65+
| option name | type | default value |
66+
67+
## Config Examples
68+
69+
Show examples of likely configurations.
70+
71+
## Credits
72+
73+
Add credits if needed.

_includes/base.njk

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Plugin Test Page</title>
7+
</head>
8+
<body>
9+
{{ content | safe }}
10+
</body>
11+
</html>

index.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
layout: base.njk
3+
---
4+
5+
## Plugin Test Page
6+
7+
Cupcake ipsum dolor. Sit amet I love I love I love. I love pudding dragée. Halvah macaroon halvah I love jujubes bonbon I love pie. Bonbon gingerbread bonbon I love. Tootsie roll chocolate sweet jelly-o lemon drops cotton candy gummies.
8+
9+
Marshmallow macaroon cupcake I love I love jelly beans pudding pastry pie. Macaroon marzipan dragée cake marshmallow I love wafer oat cake. Cake marshmallow muffin cupcake danish. Chocolate cake croissant tiramisu lollipop jelly lollipop cookie caramels cookie. Fruitcake soufflé bonbon cupcake gingerbread I love jelly beans ice cream bonbon. Sugar plum marshmallow marshmallow cake apple pie marzipan sweet tootsie roll croissant.
10+
11+
```js
12+
module.exports = function (eleventyConfig) {
13+
return {
14+
dir: {
15+
input: "src",
16+
output: "public",
17+
},
18+
};
19+
};
20+
```
21+
22+
Gummi bears chocolate bar gummi bears gummies. Soufflé soufflé dessert wafer carrot cake. Bonbon sesame snaps danish soufflé topping danish. Tart danish tootsie roll candy canes cotton candy lemon drops toffee fruitcake. Toffee gummies icing jelly beans toffee halvah. Caramels oat cake cookie topping caramels. Sesame snaps chocolate jujubes pie cake. Brownie chocolate sweet roll jelly-o. Apple pie I love jelly cake cake dragée danish candy. Tart caramels gummi bears bear claw sweet roll marzipan sweet marzipan pie.
23+
24+
Gummi bears candy cotton candy oat cake candy canes bonbon cake. Gummi bears jelly marzipan. Dessert topping biscuit jujubes jelly beans caramels cookie. Gingerbread candy gummi bears I love topping cookie halvah carrot cake topping. Sugar plum tart liquorice liquorice candy pudding powder. I love I love halvah chocolate cake I love cake apple pie wafer.
25+
26+
![test image](http://placecorgi.com/800/200)
27+
28+
I love lollipop chocolate cake marshmallow sesame snaps. Tart gingerbread fruitcake icing sesame snaps danish sesame snaps soufflé jujubes. Halvah I love I love lemon drops. Donut I love candy canes I love dragée sugar plum. I love tootsie roll I love cake. Cupcake danish danish macaroon lemon drops liquorice chocolate tart.
29+
30+
Sugar plum jelly sesame snaps I love powder. Chocolate sesame snaps cake. Pastry brownie donut I love liquorice tootsie roll. Gummi bears sesame snaps I love cookie tootsie roll. I love lemon drops topping toffee cake I love chocolate bar. Biscuit candy sweet candy canes danish danish cake. Marzipan tiramisu sweet roll fruitcake. Jujubes I love candy canes.
31+
32+
Chocolate bar pudding ice cream. Jelly-o tootsie roll pie gingerbread candy jelly beans cupcake donut lollipop. Croissant topping cake apple pie gummi bears gingerbread donut croissant tiramisu. Gummies chupa chups donut caramels gummies cotton candy cookie muffin pudding. Chocolate cake dessert bonbon I love. Marzipan jujubes jelly beans. I love wafer cookie carrot cake caramels sesame snaps cotton candy marshmallow.
33+
34+
Gummies toffee I love danish I love macaroon sesame snaps cookie. Macaroon lollipop apple pie powder marzipan bonbon brownie sweet roll I love. Gummi bears ice cream pie oat cake cupcake wafer sesame snaps. Sweet brownie icing. Tart sweet sugar plum danish cupcake I love. Fruitcake tart sweet roll soufflé. Muffin ice cream I love I love sugar plum jujubes carrot cake wafer I love. Icing brownie cake I love sugar plum I love cake.

package.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "@scope/plugin-name",
3+
"version": "1.0.0",
4+
"description": "Description of plugin",
5+
"homepage": "",
6+
"main": ".eleventy.js",
7+
"scripts": {
8+
"start": "eleventy --serve",
9+
"build": "eleventy",
10+
"bump": "npm --no-git-tag-version version"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/username/repo-name.git"
15+
},
16+
"keywords": [
17+
"11ty",
18+
"11ty-plugin",
19+
"eleventy",
20+
"eleventy-plugin"
21+
],
22+
"author": {
23+
"name": "username",
24+
"url": "https://website.com"
25+
},
26+
"license": "ISC",
27+
"bugs": {
28+
"url": "https://github.com/username/repo-name/issues"
29+
},
30+
"devDependencies": {
31+
"@11ty/eleventy": "^0.11.1"
32+
}
33+
}

0 commit comments

Comments
 (0)