Skip to content

Commit 835baa6

Browse files
committed
Add renderer docs
1 parent 6285b19 commit 835baa6

File tree

1 file changed

+66
-2
lines changed

1 file changed

+66
-2
lines changed

docs/README.md

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,69 @@
22

33
## vue-notion `NotionRenderer`
44

5-
_coming soon..._
5+
The `NotionRenderer` component offers a few properties
6+
7+
- [`blockMap`](#blockMap) – required
8+
- [`contentId`](#contentId) – default: `undefined`
9+
- [`fullPage`](#fullPage) – default: `false`
10+
- [`hideList`](#hideList) – default: `[]`
11+
- [`mapImageUrl`](#mapImageUrl) – default: `defaultMapImageUrl()`
12+
- [`mapPageUrl`](#mapPageUrl) – default: `defaultMapPageUrl()`
13+
- [`pageLinkOptions`](#pageLinkOptions) – default: `undefined`
14+
15+
### `blockMap`
16+
17+
– the blocks part of a Notion API response.
18+
A list of blocks by their id that may contain contents and properties.
19+
20+
### `contentId`
21+
22+
– the id of the block that should be rendered.
23+
If this is `undefined` the _first_ block is rendered.
24+
_Usually the first block contains the rest of the page._
25+
26+
### `fullPage`
27+
28+
– wether or not the page should contain the cover and header.
29+
30+
### `hideList`
31+
32+
– a list of Notion blocks (e.g. `"callout"`) that should not be rendered.
33+
34+
### `mapImageUrl`
35+
36+
– a method that receives `(imageUrl: String, block: Object)` and returns a `url: String` that should be used during rendering.
37+
The default method resolves images as they are used in Notion.
38+
39+
> This method could be used to upload the Notion hosted images to an own provider and replace the image URLs with new ones.
40+
41+
### `mapPageUrl`
42+
43+
– a method that receives `(pageId: String)` and returns a `url: String` that should be used during rendering.
44+
The default method resolves pageIds relative to the current page root – i.e., `<pageId>` will become `/<pageId>`
45+
46+
e.g. if you're using vue-notion for blog posts at `/posts/<pageId>`
47+
48+
```js
49+
mapPageUrl(pageId = "") {
50+
pageId = pageId.replace(/-/g, "");
51+
return `/posts/${pageId}`;
52+
}
53+
```
54+
55+
### `pageLinkOptions`
56+
57+
– are used to override links to other Notion pages with custom Vue components.
58+
`pageLinkOptions` is an `Object` that requires a `component` and a `href` parameter.
59+
60+
e.g. to use `NuxtLink` components instead of HTML `a` elements
61+
62+
```js
63+
pageLinkOptions: {
64+
component: "NuxtLink",
65+
href: "to"
66+
}
67+
```
668

769
## Notion API
870

@@ -32,11 +94,13 @@ There are a few required steps to allow Nuxt to work with vue-notion
3294

3395
- Install vue-notion as a dependency to your Nuxt project – `npm install vue-notion`
3496
- Add `"vue-notion"` to the `build.transpile` array in `nuxt.config.js`.
97+
3598
```js
3699
build: {
37-
transpile: ["vue-notion"]
100+
transpile: ["vue-notion"];
38101
}
39102
```
103+
40104
- Import the `NotionRenderer` in any component you want to use vue-notion in – `import { NotionRenderer } from "vue-notion"`
41105
- Voila, you can now use vue-notion as shown in the examples.
42106

0 commit comments

Comments
 (0)