Skip to content

Commit

Permalink
dev: Run prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
webketje committed Dec 14, 2021
1 parent 71d6f65 commit 5f0ba7c
Show file tree
Hide file tree
Showing 9 changed files with 372 additions and 371 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ extends:
- 'eslint:recommended'
- 'prettier'
parserOptions:
ecmaVersion: 2017
ecmaVersion: 2017
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
test/fixtures/**
.nyc_output/**
package-lock.json
4 changes: 2 additions & 2 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
trailingComma: none
tabWidth: 2
semi: true
semi: false
singleQuote: true
bracketSpacing: true
arrowParens: always
printWidth: 120
printWidth: 120
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
- name: coveralls
script: npm run test && npm run coveralls

script: npm run test
script: npm run test
95 changes: 52 additions & 43 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
1.0.0 / 2018-10-17
==================
# 1.0.0 / 2018-10-17

- Fixed API and merged many PRs
- Allow metadata-based filtering with `filterBy` option
Expand All @@ -10,60 +9,70 @@
- Clear collections
- Added multiple collections syntax to Readme.md

0.7.0 / 2015-02-07
==================
# 0.7.0 / 2015-02-07

* Allow front matter and pattern collections.
* Added the ability to limit the size of a collection
* Allow collections through metadata alone
* add ability to disable next/previous references
- Allow front matter and pattern collections.
- Added the ability to limit the size of a collection
- Allow collections through metadata alone
- add ability to disable next/previous references

0.6.0 / 2014-08-12
==================
# 0.6.0 / 2014-08-12

* Added the ability to set multiple collections
* Added the ability to set multiple collections

0.5.1 / 2014-08-05
==================
# 0.5.1 / 2014-08-05

* Fixed bug with require statement
- Fixed bug with require statement

0.5.0 / 2014-08-04
==================
# 0.5.0 / 2014-08-04

* Added the ability to add metadata to collections
- Added the ability to add metadata to collections

0.4.1 - May 4, 2014
-------------------
* fix empty collections
## 0.4.1 - May 4, 2014

0.4.0 - March 25, 2014
----------------------
* add option for `sortBy` to be a sorting function
- fix empty collections

0.3.0 - March 24, 2014
----------------------
* add `collection` property to each file for pattern matches
0.4.0 - March 25, 2014

0.2.0 - March 20, 2014
----------------------
* add collections dictionary to global metadata
---

0.1.0 - March 6, 2014
---------------------
* add matching by pattern
* add shorthand for pattern matching
* add previous and next references
- add option for `sortBy` to be a sorting function

0.0.3 - February 6, 2014
------------------------
* add debug statements
* swap to `extend` from `defaults` to avoid cloning
0.3.0 - March 24, 2014

0.0.2 - February 6, 2014
------------------------
* swap to `merge` to not act on clones
---

- add `collection` property to each file for pattern matches

0.2.0 - March 20, 2014

---

- add collections dictionary to global metadata

0.1.0 - March 6, 2014

---

- add matching by pattern
- add shorthand for pattern matching
- add previous and next references

0.0.3 - February 6, 2014

---

- add debug statements
- swap to `extend` from `defaults` to avoid cloning

0.0.2 - February 6, 2014

---

- swap to `merge` to not act on clones

0.0.1 - February 5, 2014

---

0.0.1 - February 5, 2014
------------------------
:sparkles:
44 changes: 24 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ A [Metalsmith](https://github.com/metalsmith/metalsmith) plugin that lets you gr
[![ci: build][ci-badge]][ci-url]
[![code coverage][codecov-badge]][codecov-url]
[![license: MIT][license-badge]][license-url]

## Features

- can match files by `collection` metadata
Expand Down Expand Up @@ -40,13 +41,13 @@ There are two ways to create collections (they can be used together):
The simplest way to create a collection is to use a pattern to match the files you want to group together:

```js
const collections = require('@metalsmith/collections');
const collections = require('@metalsmith/collections')

metalsmith.use(
collections({
articles: '*.md'
})
);
)
```

Which is just a shorthand. You could also add additional options:
Expand All @@ -60,7 +61,7 @@ metalsmith.use(
reverse: true
}
})
);
)
```

But you can also match based on a `collection` property in each file's metadata by omitting a pattern, and adding the property to your files:
Expand All @@ -73,7 +74,7 @@ metalsmith.use(
reverse: true
}
})
);
)
```

```markdown
Expand Down Expand Up @@ -116,24 +117,24 @@ metalsmith.use(
collections({
subpages: {
sortBy: function(a, b) {
let aNum, bNum;
let aNum, bNum

aNum = +a.index;
bNum = +b.index;
aNum = +a.index
bNum = +b.index

// Test for NaN
if (aNum != aNum && bNum != bNum) return 0;
if (aNum != aNum) return 1;
if (bNum != bNum) return -1;
if (aNum != aNum && bNum != bNum) return 0
if (aNum != aNum) return 1
if (bNum != bNum) return -1

// Normal comparison, want lower numbers first
if (aNum > bNum) return 1;
if (bNum > aNum) return -1;
return 0;
if (aNum > bNum) return 1
if (bNum > aNum) return -1
return 0
}
}
})
);
)
```

The `filterBy` function is passed a single argument which corresponds to each file's metadata. You can use the metadata to perform comparisons or carry out other decision-making logic. If the function you supply evaluates to `true`, the file will be added to the collection. If it evaluates to `false`, the file will not be added.
Expand All @@ -154,7 +155,7 @@ metalsmith.use(
}
}
})
);
)
```

Collection metadata can also be assigned from a `json` or `yaml` file.
Expand All @@ -168,7 +169,7 @@ metalsmith.use(
metadata: 'path/to/file.json'
}
})
);
)
```

On each collection definition, it's possible to add a `limit` option so that the
Expand All @@ -182,7 +183,7 @@ metalsmith.use(
limit: 10
}
})
);
)
```

By adding `refer: false` to your options, it will skip adding the "next" and
Expand All @@ -195,25 +196,28 @@ metalsmith.use(
refer: false
}
})
);
)
```

### Debug

To log debug output, set the `DEBUG` environment variable to `{{ plugin.name }}`:

Linux/Mac:

```sh
DEBUG=@metalsmith/collections
```

Windows:

```cmd
set "DEBUG=@metalsmith/collections"
```

## CLI Usage

Add the `@metalsmith/collections` key to your `metalsmith.json` `plugins` key:
Add the `@metalsmith/collections` key to your `metalsmith.json` `plugins` key:

```json
{
Expand Down Expand Up @@ -243,4 +247,4 @@ Add the `@metalsmith/collections` key to your `metalsmith.json` `plugins` key:
[codecov-badge]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg
[codecov-url]: https://github.com/prettier/prettier
[license-badge]: https://img.shields.io/github/license/metalsmith/collections
[license-url]: LICENSE
[license-url]: LICENSE
Loading

0 comments on commit 5f0ba7c

Please sign in to comment.