-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6cd2a59
Showing
9 changed files
with
3,848 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[*.md] | ||
indent_style = space | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-disable valid-jsdoc */ | ||
const classnames = require( "./src/classnames" ); | ||
|
||
/** | ||
* @param {import("@11ty/eleventy/src/UserConfig")} eleventyConfig | ||
*/ | ||
module.exports = ( eleventyConfig ) => | ||
{ | ||
eleventyConfig.addShortcode( "classnames", classnames ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module.exports = { | ||
"env": { | ||
"es2021": true, | ||
"node": true, | ||
}, | ||
"extends": "eslint:recommended", | ||
"rules": { | ||
"arrow-parens": ["error", "always"], | ||
"brace-style": ["error", "allman"], | ||
"camelcase": "warn", | ||
"comma-dangle": ["error", "always-multiline"], | ||
"indent": ["error", "tab"], | ||
"max-len": [0, { | ||
"ignoreComments": true, | ||
"ignoreTrailingComments": true, | ||
"ignoreUrls": true, | ||
"ignoreStrings": true, | ||
"ignoreTemplateLiterals": true, | ||
"ignoreRegExpLiterals": true, | ||
"ignorePattern": true, | ||
}], | ||
"new-cap": "warn", | ||
"no-console": "warn", | ||
"no-invalid-this": "error", | ||
"no-negated-condition": "warn", | ||
"object-curly-spacing": ["error", "always"], | ||
"quotes": ["error", "double"], | ||
"require-jsdoc": ["error", { | ||
"require": { | ||
"FunctionDeclaration": true, | ||
}, | ||
}], | ||
"semi": ["error", "always"], | ||
"sort-requires/sort-requires": 2, | ||
"sort-vars": ["error", { | ||
"ignoreCase": true, | ||
}], | ||
"space-in-parens": ["error", "always", { | ||
"exceptions": ["empty"], | ||
}], | ||
}, | ||
"parserOptions": { | ||
"sourceType": "module", | ||
}, | ||
"plugins": [ | ||
"sort-requires", | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# eleventy-plugin-classnames | ||
|
||
An [Eleventy](https://11ty.dev/) shortcode for joining truthy, non-duplicate argument values into a space-delimited string. | ||
|
||
> Inspired by the [classnames](https://www.npmjs.com/package/classnames) package by [JedWatson](https://github.com/JedWatson/classnames) | ||
## Setup | ||
|
||
Run the following command at the root of your Eleventy project | ||
|
||
```shell | ||
npm install @aaashur/eleventy-plugin-classnames | ||
``` | ||
|
||
then include it in your `.eleventy.js` config file: | ||
|
||
```javascript | ||
const classnames = require("@aaashur/eleventy-plugin-classnames"); | ||
|
||
module.exports = (eleventyConfig) => { | ||
eleventyConfig.addPlugin(classnames); | ||
}; | ||
``` | ||
|
||
## Usage | ||
|
||
```njk | ||
{%- set color = "turquoise" -%} | ||
{%- set primary = false -%} | ||
{%- set sectionTitle = "Section Title" -%} | ||
<h2 class="{% classnames | ||
"block__element", | ||
"block__element--primary" if primary, | ||
"block__element--" + color if color | ||
%}"> | ||
{{ sectionTitle }} | ||
</h2> | ||
``` | ||
|
||
would return | ||
|
||
```html | ||
<h2 class="block__element block__element--turquoise"> | ||
Section Title | ||
</h2> | ||
``` |
Oops, something went wrong.