Update
This commit is contained in:
parent
414d1c3ac5
commit
bc7e126cd5
|
@ -23,6 +23,19 @@ A standard for flux action objects. An action may have an `error`, `payload` and
|
|||
{ type: 'ADD_TODO', payload: new Error(), error: true }
|
||||
```
|
||||
|
||||
### [redux-multi](https://github.com/ashaffer/redux-multi)
|
||||
Dispatch multiple actions in one action creator.
|
||||
|
||||
```js
|
||||
store.dispatch([
|
||||
{ type: 'INCREMENT', payload: 2 },
|
||||
{ type: 'INCREMENT', payload: 3 }
|
||||
])
|
||||
```
|
||||
|
||||
Async
|
||||
-----
|
||||
|
||||
### [redux-promise](https://github.com/acdlite/redux-promise)
|
||||
Pass promises to actions. Dispatches a flux-standard-action.
|
||||
|
||||
|
@ -61,12 +74,28 @@ Pass side effects declaratively to keep your actions pure.
|
|||
}
|
||||
```
|
||||
|
||||
### [redux-multi](https://github.com/ashaffer/redux-multi)
|
||||
Dispatch multiple actions in one action creator.
|
||||
### [redux-thunk](https://www.npmjs.com/package/redux-thunk)
|
||||
Pass "thunks" to as actions.
|
||||
|
||||
```js
|
||||
store.dispatch([
|
||||
{ type: 'INCREMENT', payload: 2 },
|
||||
{ type: 'INCREMENT', payload: 3 }
|
||||
])
|
||||
function fetchPosts () {
|
||||
// Usually returns a promise.
|
||||
return function (dispatch, getState) {
|
||||
dispatch({ type: 'posts:fetch' })
|
||||
return API.get('/posts')
|
||||
.then(payload => dispatch({ type: 'posts:fetch:done', payload })
|
||||
.then(error => dispatch({ type: 'posts:fetch:error', error })
|
||||
}
|
||||
}
|
||||
|
||||
store.dispatch(fetchPosts())
|
||||
|
||||
// That's actually shorthand for:
|
||||
fetchPosts()(store.dispatch, store.getState)
|
||||
|
||||
// Optional: since fetchPosts returns a promise, it can be chained
|
||||
// for server-side rendering
|
||||
store.dispatch(fetchPosts()).then(() => {
|
||||
ReactDOMServer.renderToString(<MyApp store={store} />)
|
||||
})
|
||||
```
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
title: Meta-tags
|
||||
category: Ruby libraries
|
||||
---
|
||||
|
||||
### Titles
|
||||
|
||||
```rb
|
||||
set_meta_tags title: 'Member Login'
|
||||
# <title>Some Page Title</title>
|
||||
set_meta_tags site: 'Site Title', title: 'Member Login'
|
||||
# <title>Site Title | Page Title</title>
|
||||
set_meta_tags site: 'Site Title', title: 'Member Login', reverse: true
|
||||
# <title>Page Title | Site Title</title>
|
||||
```
|
||||
|
||||
### Others
|
||||
|
||||
```rb
|
||||
set_meta_tags description: "All text about keywords, other keywords"
|
||||
set_meta_tags keywords: %w[abc def ghi]
|
||||
set_meta_tags noindex: true
|
||||
set_meta_tags nofollow: true
|
||||
set_meta_tags canonical: 'http://...'
|
||||
set_meta_tags icon: 'favicon.ico'
|
||||
set_meta_tags author: 'http://...'
|
||||
set_meta_tags alternate: { 'fr' => 'http://...' }
|
||||
set_meta_tags prev: 'http://...'
|
||||
set_meta_tags next: 'http://...'
|
||||
set_meta_tags og: { image: ['...'] }
|
||||
```
|
||||
|
||||
### In views
|
||||
|
||||
```rb
|
||||
<%= display_meta_tags %>
|
||||
```
|
||||
|
||||
```rb
|
||||
<% title 'Member Login' %>
|
||||
<% description 'My page' %>
|
||||
<% keywords '..' %>
|
||||
|
||||
<h1><%= title %></h1>
|
||||
```
|
||||
|
||||
### Reference
|
||||
|
||||
Accurate as of 2.1.0. See <https://github.com/kpumuk/meta-tags>.
|
Loading…
Reference in New Issue