redhead
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -1,1 +0,1 @@ | ||
{"version":"0.3.1","commands":{"build":{"id":"build","description":"Generate the platform specific files based on the configuration","pluginName":"redhead","pluginType":"core","aliases":[],"flags":{"output":{"name":"output","type":"option","char":"o","description":"Folder where the generated files should be saved.","default":"."}},"args":[]},"init":{"id":"init","description":"Initialize the required files\n\nGenerates files for handling your headers and/or redirects configuration.\n","pluginName":"redhead","pluginType":"core","aliases":[],"flags":{"no-headers":{"name":"no-headers","type":"boolean","char":"h","description":"Whether or not to handle headers with redhead","allowNo":false},"no-redirects":{"name":"no-redirects","type":"boolean","char":"r","description":"Whether or not to handle redirects with redhead","allowNo":false}},"args":[]}}} | ||
{"version":"0.3.2","commands":{"build":{"id":"build","description":"Generate the platform specific files based on the configuration","pluginName":"redhead","pluginType":"core","aliases":[],"flags":{"output":{"name":"output","type":"option","char":"o","description":"Folder where the generated files should be saved.","default":"."}},"args":[]},"init":{"id":"init","description":"Initialize the required files\n\nGenerates files for handling your headers and/or redirects configuration.\n","pluginName":"redhead","pluginType":"core","aliases":[],"flags":{"no-headers":{"name":"no-headers","type":"boolean","char":"h","description":"Whether or not to handle headers with redhead","allowNo":false},"no-redirects":{"name":"no-redirects","type":"boolean","char":"r","description":"Whether or not to handle redirects with redhead","allowNo":false}},"args":[]}}} |
{ | ||
"name": "redhead", | ||
"description": "Dynamically setup headers and redirects for you static deployments", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"bin": { | ||
@@ -6,0 +6,0 @@ "redhead": "./bin/run" |
@@ -29,10 +29,15 @@ RedHead | ||
<!-- toc --> | ||
<p align="center"><strong>WARNING:</strong> This is still in active development, make sure you lock your versions!<p> | ||
<!-- tocstop --> | ||
## Table of content | ||
* [Installation](#installation) | ||
* [Usage](#usage) | ||
* [Commands](#commands) | ||
* [init](#redhead-init) | ||
* [build](#redhead-build) | ||
* [help](#redhead-help-command) | ||
* [Examples](#examples) | ||
* [Contributing](#contributing) | ||
* [Credits](#credits) | ||
<!-- installation --> | ||
<p align="center"><strong>WARNING:</strong> This is still in active development, make sure you lock your versions!<p> | ||
## Installation | ||
@@ -49,3 +54,2 @@ | ||
``` | ||
<!-- installationstop --> | ||
@@ -58,3 +62,3 @@ <!-- usage --> | ||
$ redhead (-v|--version|version) | ||
redhead/0.3.1 darwin-x64 node-v10.15.0 | ||
redhead/0.3.2 darwin-x64 node-v10.15.1 | ||
$ redhead --help [COMMAND] | ||
@@ -84,3 +88,3 @@ USAGE | ||
_See code: [src/commands/build.js](https://github.com/streaver/redhead/blob/v0.3.1/src/commands/build.js)_ | ||
_See code: [src/commands/build.js](https://github.com/streaver/redhead/blob/v0.3.2/src/commands/build.js)_ | ||
@@ -120,37 +124,49 @@ ## `redhead help [COMMAND]` | ||
_See code: [src/commands/init.js](https://github.com/streaver/redhead/blob/v0.3.1/src/commands/init.js)_ | ||
_See code: [src/commands/init.js](https://github.com/streaver/redhead/blob/v0.3.2/src/commands/init.js)_ | ||
<!-- commandsstop --> | ||
## `redhead build` | ||
## Examples | ||
Generate the platform specific files based on the configuration. Currently only [Netlify](https://netlify.com) is supported, but we plan to add support for [Firebase Hosting](https://firebase.google.com/docs/hosting/) and [Heroku Buildpack Static](https://github.com/heroku/heroku-buildpack-static) | ||
### Different config based on environment | ||
``` | ||
USAGE | ||
$ redhead build | ||
For example, if you want to have different headers based on the environment you just need to customize the `headers.js` file for your needs and make sure you ENV variables are set for each case, for Netlify this could be done via the `netlify.toml` file. | ||
OPTIONS | ||
-o, --output=output [default: .] Folder where the generated files should be saved. | ||
``` | ||
```js | ||
// .redhead/headers.js | ||
_See code: [src/commands/build.js](https://github.com/streaver/redhead/blob/v0.3.0/src/commands/build.js)_ | ||
const headers = []; | ||
## `redhead help [COMMAND]` | ||
if (process.env.NODE_ENV === 'production') { | ||
headers.push({ | ||
path: '/cool', | ||
headers: [ | ||
'X-Cool: 123' | ||
], | ||
}); | ||
} | ||
display help for redhead | ||
module.exports = headers; | ||
``` | ||
USAGE | ||
$ redhead help [COMMAND] | ||
ARGUMENTS | ||
COMMAND command to show help for | ||
### Redirecting one path to the latest post | ||
OPTIONS | ||
--all see all commands in CLI | ||
Let's say you have a blog and want to have a `/latest` path that always takes users to the latest post that has been published, this could be easily achieved with RedHead. | ||
```js | ||
// .redhead/redirects.js | ||
// use your DB library here; | ||
const db = require('db').config(process.env.CONNECTION_URL); | ||
const lastPost = db.posts.last(); | ||
module.exports = [{ | ||
from: '/latest', | ||
to: `${lastPost.permalink}`, | ||
status: '302', | ||
options: '', | ||
}]; | ||
``` | ||
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.1.4/src/commands/help.ts)_ | ||
<!-- contributing --> | ||
## Contributing | ||
@@ -162,8 +178,4 @@ | ||
<!-- contributingstop --> | ||
<!-- credits --> | ||
## Credits | ||
- <div>Icon made by <a href="https://www.freepik.com/" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div> | ||
<!-- creditsstop --> |
13114
176