1
0
mirror of https://github.com/kremalicious/gatsby-redirect-from.git synced 2024-12-22 17:23:24 +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": [ "presets": [["@babel/env"]]
["@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"], "extends": ["eslint:recommended", "plugin:prettier/recommended"],
"rules": { "plugins": ["prettier"],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never"
]
},
"parserOptions": { "parserOptions": {
"sourceType": "module", "sourceType": "module",
"ecmaFeatures": { "ecmaFeatures": {

5
.prettierrc Normal file
View File

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

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). > 🎯 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) - [Prerequisites](#prerequisites)
- [Installation](#installation) - [Installation](#installation)
- [Server Rendering](#server-rendering) - [Server Rendering](#server-rendering)
- [Usage](#usage) - [Usage](#usage)
- [Plugin Development](#plugin-development) - [Options](#options)
- [License](#license) - [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. 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 ## Installation
```bash ```bash
@ -44,6 +47,8 @@ plugins: [
] ]
``` ```
That's it. See [Usage](#usage).
### Server Rendering ### 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. 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 ## Plugin Development
```bash ```bash
@ -80,15 +107,15 @@ npm run build
# publishing to npm & GitHub releases # publishing to npm & GitHub releases
# uses https://github.com/webpro/release-it # uses https://github.com/webpro/release-it
npm run release npm run release
npm run release-minor npm run release minor
npm run release-major npm run release major
``` ```
## License ## License
The MIT 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: 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__", "build": "babel src --out-dir . --ignore __tests__",
"start": "babel -w src --out-dir . --ignore __tests__", "start": "babel -w src --out-dir . --ignore __tests__",
"test": "eslint ./src/**/*.js", "test": "eslint ./src/**/*.js",
"release": "./node_modules/release-it/bin/release-it.js --src.tagName='v%s' --github.release --npm.publish --non-interactive", "format": "prettier --write 'src/**/*.{js,jsx}'",
"release-minor": "./node_modules/release-it/bin/release-it.js minor --src.tagName='v%s' --github.release --npm.publish --non-interactive", "release": "release-it --non-interactive",
"release-major": "./node_modules/release-it/bin/release-it.js major --src.tagName='v%s' --github.release --npm.publish --non-interactive", "changelog": "auto-changelog -p",
"prepublishOnly": "cross-env NODE_ENV=production npm run build" "prepublishOnly": "cross-env NODE_ENV=production npm run build"
}, },
"browserslist": [ "browserslist": [
"last 2 versions" "maintained node versions"
], ],
"dependencies": { "dependencies": {},
"chalk": "^2.4.1"
},
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.0.0", "@babel/cli": "^7.4.4",
"@babel/core": "^7.0.0", "@babel/core": "^7.4.5",
"@babel/preset-env": "^7.0.0", "@babel/preset-env": "^7.4.5",
"auto-changelog": "^1.13.0",
"chalk": "^2.4.2",
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
"eslint": "^5.4.0", "eslint": "^5.16.0",
"release-it": "^8.0.0" "eslint-config-prettier": "^4.3.0",
"eslint-plugin-prettier": "^3.1.0",
"prettier": "^1.18.2",
"release-it": "^12.3.0"
}, },
"peerDependencies": { "peerDependencies": {
"gatsby": ">=2", "gatsby": ">=2",
"gatsby-plugin-meta-redirect": ">=1.1.0" "gatsby-plugin-meta-redirect": ">=1.1.0"
}, },
"engines": { "engines": {
"node": "^8.0.0" "node": ">=8.0.0"
}, },
"repository": "github:kremalicious/gatsby-redirect-from", "repository": "github:kremalicious/gatsby-redirect-from",
"bugs": { "bugs": {
@ -44,5 +47,20 @@
"gatsby", "gatsby",
"gatsby-plugin", "gatsby-plugin",
"redirect" "redirect"
] ],
"release-it": {
"scripts": {
"beforeStart": "npm test",
"beforeStage": "npm run changelog"
},
"git": {
"tagName": "v${version}"
},
"github": {
"release": true
},
"npm": {
"publish": true
}
}
} }