Skip to content

Commit

Permalink
Aligned dotfiles & repo files with core plugins. Added LICENSE, updat…
Browse files Browse the repository at this point in the history
…ed devDependencies
  • Loading branch information
webketje committed Dec 14, 2021
1 parent c57dab3 commit 0f2480b
Show file tree
Hide file tree
Showing 18 changed files with 8,016 additions and 133 deletions.
10 changes: 5 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
root = true

[*]
charset = utf-8

[*.{js,json}]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

25 changes: 0 additions & 25 deletions .eslintrc

This file was deleted.

8 changes: 8 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
env:
node: true
es6: true
extends:
- 'eslint:recommended'
- 'prettier'
parserOptions:
ecmaVersion: 2017
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Automatically normalize line endings for all text-based files
# http://git-scm.com/docs/gitattributes#_end_of_line_conversion
* text=auto

# For the following file types, normalize line endings to LF on
# checkin and prevent conversion to CRLF when they are checked out
# (this is required in order to prevent newline related issues like,
# for example, after the build script is run)
.* text eol=lf
*.css text eol=lf
*.html text eol=lf
*.js text eol=lf
*.json text eol=lf
*.md text eol=lf
*.sh text eol=lf
*.txt text eol=lf
*.xml text eol=lf
44 changes: 5 additions & 39 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,42 +1,8 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed
*.swp

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Package Lock
package-lock.json

# ESLint Cache
*.tgz
.eslintcache

test/**/build
.nyc_output
coverage.info
test/fixtures/*/build
node_modules
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
package-lock.json
package.json
test/fixtures/**
.nyc_output/**
3 changes: 0 additions & 3 deletions .prettierrc

This file was deleted.

7 changes: 7 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
trailingComma: none
tabWidth: 2
semi: true
singleQuote: true
bracketSpacing: true
arrowParens: always
printWidth: 120
24 changes: 24 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"hooks": {
"before:init": ["npm run lint", "npm test"],
"after:bump": "auto-changelog --sort-commits date-desc -p --starting-date 2021-12-01 --commit-limit false --ignore-commit-pattern '(dev|Release)'",
"after:npm:bump": "npm pack",
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
},
"git": {
"commitMessage": "Release ${version}",
"commitArgs": ["-S"],
"tagAnnotation": "Release ${version}",
"tagArgs": ["-s"],
"changelog": "auto-changelog --sort-commits date-desc -u --starting-date 2021-12-01 --commit-limit false --ignore-commit-pattern '(dev|Release)' --stdout"
},
"npm": {
"publish": false
},
"github": {
"release": true,
"releaseName": "@metalsmith/collections ${version}",
"tokenRef": "GITHUB_TOKEN",
"assets": ["metalsmith-collections-${version}.tgz"]
}
}
24 changes: 19 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
language: node_js
dist: xenial

node_js:
- "node"
- "9"
- "8"
- "7"
- "6"
- node
- 16
- 12
- 8

os:
- linux
- windows

jobs:
include:
- name: lint
script: npm run lint
- name: coveralls
script: npm run test && npm run coveralls

script: npm run test
1 change: 0 additions & 1 deletion History.md → CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
- Clear collections
- Added multiple collections syntax to Readme.md


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

Expand Down
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2021 webketje
Copyright (c) 2014-2021 Segment

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
86 changes: 57 additions & 29 deletions Readme.md → README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# metalsmith-collections
# @metalsmith/collections

[![npm version][npm-badge]][npm-url]
[![code style: prettier][prettier-badge]][prettier-url]
[![metalsmith: plugin][metalsmith-badge]][metalsmith-url]

[![Build Status][travis-badge]][travis-url]

A [Metalsmith](https://github.com/segmentio/metalsmith) plugin that lets you group files together into an ordered collection, like blog posts. That way you can loop over them to generate an index, or add 'next' and 'previous' links between them.
A [Metalsmith](https://github.com/metalsmith/metalsmith) plugin that lets you group files together into an ordered collection, like blog posts. That way you can loop over them to generate an index, or add 'next' and 'previous' links between them.

[![metalsmith: core plugin][metalsmith-badge]][metalsmith-url]
[![npm version][npm-badge]][npm-url]
[![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 All @@ -19,19 +18,29 @@ A [Metalsmith](https://github.com/segmentio/metalsmith) plugin that lets you gro

## Installation

$ npm install metalsmith-collections
NPM:

```
npm install @metalsmith/collections
```

Yarn:

```
yarn add @metalsmith/collections
```

## Usage

There are two ways to create collections:
There are two ways to create collections (they can be used together):

- **by pattern** - this is just passing a globbing pattern that will group any files that match into the same collection. The passed pattern can be a single pattern (as a string) or an array of globing patterns. For more information read the [multimatch patterns documentation](https://www.npmjs.com/package/multimatch#how-multiple-patterns-work).
- **by metadata** - this is adding a specific `collection` metadata field to each item that you want to add to a collection.

The simplest way to create a collection is to use a pattern to match the files you want to group together:

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

metalsmith.use(
collections({
Expand Down Expand Up @@ -81,10 +90,12 @@ Multiple collections can also be assigned per file:

```markdown
---

title: My Article
collection: - articles - news
date: 2016-02-11
collection:
- articles
- news
date: 2021-12-01
---

My article contents...
```
Expand All @@ -105,7 +116,7 @@ metalsmith.use(
collections({
subpages: {
sortBy: function(a, b) {
var aNum, bNum;
let aNum, bNum;

aNum = +a.index;
bNum = +b.index;
Expand Down Expand Up @@ -187,32 +198,49 @@ metalsmith.use(
);
```

### 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

All of the same options apply, just add them to the `"plugins"` key in your `metalsmith.json` configuration:
Add the `@metalsmith/collections` key to your `metalsmith.json` `plugins` key:

```json
{
"plugins": {
"metalsmith-collections": {
"articles": {
"sortBy": "date",
"reverse": true
"plugins": [
{
"@metalsmith/collections": {
"articles": {
"sortBy": "date",
"reverse": true
}
}
}
}
]
}
```

## License

MIT
[MIT](LICENSE)

[npm-badge]: https://img.shields.io/npm/v/metalsmith-collections.svg
[npm-url]: https://www.npmjs.com/package/metalsmith-collections
[travis-badge]: https://travis-ci.org/segmentio/metalsmith-collections.svg?branch=master
[travis-url]: https://travis-ci.org/segmentio/metalsmith-collections
[prettier-badge]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg
[prettier-url]: https://github.com/prettier/prettier
[npm-badge]: https://img.shields.io/npm/v/@metalsmith/collections.svg
[npm-url]: https://www.npmjs.com/package/@metalsmith/collections
[ci-badge]: https://app.travis-ci.com/github/metalsmith/collections.svg?branch=master
[ci-url]: https://app.travis-ci.com/github/metalsmith/collections
[metalsmith-badge]: https://img.shields.io/badge/metalsmith-plugin-green.svg?longCache=true
[metalsmith-url]: http://metalsmith.io
[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
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var debug = require('debug')('metalsmith-collections');
var debug = require('debug')('@metalsmith/collections');
var multimatch = require('multimatch');
var unique = require('uniq');
var loadMetadata = require('read-metadata').sync;
Expand Down
Loading

0 comments on commit 0f2480b

Please sign in to comment.