|
2 | 2 |
|
3 | 3 | ## vue-notion `NotionRenderer` |
4 | 4 |
|
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 | +``` |
6 | 68 |
|
7 | 69 | ## Notion API |
8 | 70 |
|
@@ -32,11 +94,13 @@ There are a few required steps to allow Nuxt to work with vue-notion |
32 | 94 |
|
33 | 95 | - Install vue-notion as a dependency to your Nuxt project – `npm install vue-notion` |
34 | 96 | - Add `"vue-notion"` to the `build.transpile` array in `nuxt.config.js`. |
| 97 | + |
35 | 98 | ```js |
36 | 99 | build: { |
37 | | - transpile: ["vue-notion"] |
| 100 | + transpile: ["vue-notion"]; |
38 | 101 | } |
39 | 102 | ``` |
| 103 | + |
40 | 104 | - Import the `NotionRenderer` in any component you want to use vue-notion in – `import { NotionRenderer } from "vue-notion"` |
41 | 105 | - Voila, you can now use vue-notion as shown in the examples. |
42 | 106 |
|
|
0 commit comments