1
0
mirror of https://github.com/kremalicious/gatsby-redirect-from.git synced 2024-12-22 09:13:20 +01:00

Merge pull request #12 from kremalicious/fixes

Update docs & dependencies
This commit is contained in:
Matthias Kretschmann 2019-06-11 00:41:58 +02:00 committed by GitHub
commit 5fff01c864
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 79 additions and 45 deletions

View File

@ -1,5 +1,3 @@
{
"presets": [
["@babel/env"]
]
"presets": [["@babel/env"]]
}

View File

@ -1,5 +0,0 @@
version: "2"
checks:
method-lines:
config:
threshold: 30

View File

@ -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": {

5
.prettierrc Normal file
View File

@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "none"
}

View File

@ -2,4 +2,4 @@ language: node_js
node_js: node
notifications:
email: false
email: false

View File

@ -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)
---
@ -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
@ -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.
@ -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
@ -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:

View File

@ -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": {
@ -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
}
}
}