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

Remove URL from frontity exports #206

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 2 additions & 38 deletions docs/api-reference-1/frontity.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@ You can read more in the [Code Splitting](../learning-frontity/code-splitting.md

* [loadable](frontity.md#loadable)

### `fetch` and `URL`
### `fetch`

Frontity exports `fetch` and `URL` with the same API they have in the browser, but they work the same both in the client and in the server.
Frontity exports `fetch` with the same API it has in the browser, but it works the same both in the client and in the server.

#### **API reference:**

* [fetch](frontity.md#fetch)
* [URL](frontity.md#url)

### Helpers

Expand Down Expand Up @@ -577,41 +576,6 @@ const getFromSomeAPI = async (resource) => {
};
```

### `URL`

#### Syntax

```javascript
const url = new URL(url, base);
```

It's a constructor with the [WHATWG API](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) to create [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) objects.

This constructor is safe to use both server and client side, but you have to import it first.

#### Arguments

* **`url`**: a string representing an absolute or relative URL

If `url` is a relative URL, `base` is required

* **`base`**: a string representing the base URL to use in case `url` is a relative URL

#### Return value

* A [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL)object

#### Example

```jsx
import { URL } from "frontity";

const getApiPathname = ({ state }) => {
const { pathname } = new URL(state.source.api);
return pathname;
};
```

### `decode`

An entity decoder that decodes HTML numeric entities and [XML named entities](https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references). It works both in the server and the client and it's optimized to be both lightweight and performant.
Expand Down