Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(v2): Redirect component for easy redirect #1913

Merged
merged 5 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG-2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
## Unreleased

- Reduce memory usage consumption.
- Add `<Redirect>` component for easy client side redirect.
Example Uaage:
```js
import React from 'react';
import {Redirect} from '@docusaurus/router';

function Home() {
return <Redirect to="/docs/test" />;
}
```
- Slightly adjust search icon position to be more aligned on small width device.
- Convert sitemap plugin to TypeScript.
- Significantly reduce main bundle size and initial HTML payload on production build. Generated JS files from webpack is also shorter in name.
Expand Down
18 changes: 17 additions & 1 deletion website/docs/docusaurus-core.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
id: docusaurus-core
title: Docusaurus Core API
title: Docusaurus Client API
sidebar_title: Client API
---

Docusaurus provides some API on client that can be helpful when building your site.
Expand Down Expand Up @@ -143,3 +144,18 @@ function Help() {
);
}
```

## `<Redirect />`

Rendering a `<Redirect>` will navigate to a new location. The new location will override the current location in the history stack, like server-side redirects (HTTP 3xx) do. You can refer to [React Router's Redirect documentation](https://reacttraining.com/react-router/web/api/Redirect) for more info on available props.

Example usage:

```jsx {2,5}
import React from 'react';
import {Redirect} from '@docusaurus/router';

function Home() {
return <Redirect to="/docs/test" />;
}
```