Skip to content

Commit

Permalink
Merge pull request #12 from kremalicious/fixes
Browse files Browse the repository at this point in the history
Update docs & dependencies
  • Loading branch information
kremalicious committed Jun 10, 2019
2 parents 63102f3 + 420b364 commit 5fff01c
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 45 deletions.
4 changes: 1 addition & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"presets": [
["@babel/env"]
]
"presets": [["@babel/env"]]
}
5 changes: 0 additions & 5 deletions .codeclimate.yml

This file was deleted.

13 changes: 2 additions & 11 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
{
"extends": ["eslint:recommended"],
"rules": {
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never"
]
},
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"plugins": ["prettier"],
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
Expand Down
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "none"
}
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ language: node_js
node_js: node

notifications:
email: false
email: false
49 changes: 38 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@

> 🎯 Set redirect urls in your YAML frontmatter within your [Gatsby](https://www.gatsbyjs.org) site's Markdown files. Mimics the behavior of [jekyll-redirect-from](https://github.com/jekyll/jekyll-redirect-from).
By adding a list of urls to the YAML frontmatter, this plugin creates redirects for all of them at build time. It uses Gatsby's [createRedirect](https://next.gatsbyjs.org/docs/actions/#createRedirect) under the hood.
By adding a list of urls to the YAML frontmatter, this plugin creates redirects for all of them at build time. It uses Gatsby's [createRedirect](https://www.gatsbyjs.org/docs/actions/#createRedirect) under the hood.

## Table of Contents
**Table of Contents**

- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Server Rendering](#server-rendering)
- [Usage](#usage)
- [Plugin Development](#plugin-development)
- [License](#license)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Server Rendering](#server-rendering)
- [Usage](#usage)
- [Options](#options)
- [Plugin Development](#plugin-development)
- [License](#license)

---

Expand All @@ -28,6 +29,8 @@ By adding a list of urls to the YAML frontmatter, this plugin creates redirects

Plugin assumes the default setup from [gatsby-starter-blog](https://github.com/gatsbyjs/gatsby-starter-blog), with Markdown files processing by [gatsby-transformer-remark](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-transformer-remark) and adding a field `slug` for each file node. Head over to gatsby-starter-blog's [gatsby-node.js](https://github.com/gatsbyjs/gatsby-starter-blog/blob/master/gatsby-node.js#L57) file to see how this is done.

If this does not fit your setup, you can [configure the default `query`](#options) being used.

## Installation

```bash
Expand All @@ -44,6 +47,8 @@ plugins: [
]
```

That's it. See [Usage](#usage).

### Server Rendering

Gatsby's `createRedirect` only creates client-side redirects, so further integration is needed to get server redirects too. Which is highly dependent on your hosting, if you want to have the proper HTML status codes like `301`, Apache needs `.htaccess` rules for that, nginx `rewrite` rules, S3 `RoutingRules` and so on.
Expand All @@ -68,6 +73,28 @@ redirect_from:
---
```

## Options

Plugin does not require to be configured but some additional customization options are available:

| Option | Default | Description |
| ------ | ------------------- | ------------------------------------------------------------------------------------------------ |
| query | `allMarkdownRemark` | Modify the query being used to get the frontmatter data. E.g. if you use MDX, set `allMdx` here. |

Add options to the plugins's configuration object in `gatsby-config.js` like so:

```js
plugins: [
{
resolve: 'gatsby-redirect-from',
options: {
query: 'allMdx'
}
}
'gatsby-plugin-meta-redirect' // make sure this is always the last one
]
```

## Plugin Development

```bash
Expand All @@ -80,15 +107,15 @@ npm run build
# publishing to npm & GitHub releases
# uses https://github.com/webpro/release-it
npm run release
npm run release-minor
npm run release-major
npm run release minor
npm run release major
```

## License

The MIT License

Copyright (c) 2018 Matthias Kretschmann
Copyright (c) 2019 Matthias Kretschmann

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:

Expand Down
46 changes: 32 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,34 @@
"build": "babel src --out-dir . --ignore __tests__",
"start": "babel -w src --out-dir . --ignore __tests__",
"test": "eslint ./src/**/*.js",
"release": "./node_modules/release-it/bin/release-it.js --src.tagName='v%s' --github.release --npm.publish --non-interactive",
"release-minor": "./node_modules/release-it/bin/release-it.js minor --src.tagName='v%s' --github.release --npm.publish --non-interactive",
"release-major": "./node_modules/release-it/bin/release-it.js major --src.tagName='v%s' --github.release --npm.publish --non-interactive",
"format": "prettier --write 'src/**/*.{js,jsx}'",
"release": "release-it --non-interactive",
"changelog": "auto-changelog -p",
"prepublishOnly": "cross-env NODE_ENV=production npm run build"
},
"browserslist": [
"last 2 versions"
"maintained node versions"
],
"dependencies": {
"chalk": "^2.4.1"
},
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"auto-changelog": "^1.13.0",
"chalk": "^2.4.2",
"cross-env": "^5.2.0",
"eslint": "^5.4.0",
"release-it": "^8.0.0"
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-prettier": "^3.1.0",
"prettier": "^1.18.2",
"release-it": "^12.3.0"
},
"peerDependencies": {
"gatsby": ">=2",
"gatsby-plugin-meta-redirect": ">=1.1.0"
},
"engines": {
"node": "^8.0.0"
"node": ">=8.0.0"
},
"repository": "github:kremalicious/gatsby-redirect-from",
"bugs": {
Expand All @@ -44,5 +47,20 @@
"gatsby",
"gatsby-plugin",
"redirect"
]
],
"release-it": {
"scripts": {
"beforeStart": "npm test",
"beforeStage": "npm run changelog"
},
"git": {
"tagName": "v${version}"
},
"github": {
"release": true
},
"npm": {
"publish": true
}
}
}

0 comments on commit 5fff01c

Please sign in to comment.