Skip to content

Commit 9372251

Browse files
committed
Merge branch 'add-nuxt-module' into add-nuxt-module-v3
2 parents f2a9aab + 629e276 commit 9372251

File tree

9 files changed

+143
-96
lines changed

9 files changed

+143
-96
lines changed

.gitignore

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
yarn.lock
12

2-
# Created by https://www.toptal.com/developers/gitignore/api/macOS,Node,Vuejs,Vue
3-
# Edit at https://www.toptal.com/developers/gitignore?templates=macOS,Node,Vuejs,Vue
3+
# Created by https://www.toptal.com/developers/gitignore/api/Node,macOS,Vue,Vuejs,yarn
4+
# Edit at https://www.toptal.com/developers/gitignore?templates=Node,macOS,Vue,Vuejs,yarn
45

56
### macOS ###
67
# General
@@ -9,7 +10,8 @@
910
.LSOverride
1011

1112
# Icon must end with two \r
12-
Icon
13+
Icon
14+
1315

1416
# Thumbnails
1517
._*
@@ -159,4 +161,20 @@ dist/
159161
npm-debug.log
160162
yarn-error.log
161163

162-
# End of https://www.toptal.com/developers/gitignore/api/macOS,Node,Vuejs,Vue
164+
### yarn ###
165+
# https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored
166+
167+
.yarn/*
168+
!.yarn/releases
169+
!.yarn/plugins
170+
!.yarn/sdks
171+
!.yarn/versions
172+
173+
# if you are NOT using Zero-installs, then:
174+
# comment the following lines
175+
!.yarn/cache
176+
177+
# and uncomment the following lines
178+
# .pnp.*
179+
180+
# End of https://www.toptal.com/developers/gitignore/api/Node,macOS,Vue,Vuejs,yarn

README.md

Lines changed: 63 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<span> · </span>
99
<a href="#install">Install</a>
1010
<span> · </span>
11-
<a href="#basic-example">Example</a>
12-
<span> · </span>
1311
<a href="#docs">Docs</a>
1412
<span> · </span>
13+
<a href="#examples">Examples</a>
14+
<span> · </span>
1515
<a href="#credits">Credits</a>
1616
</h3>
1717

@@ -49,40 +49,48 @@ This package doesn't handle the communication with the API. Check out [notion-ap
4949

5050
🔮 **Syntax-Highlighting** – Beautiful themeable code highlighting using Prism.js
5151

52-
🌎 **SSR / Static Generation Support** – Functions to work with Nuxt and other frameworks
52+
🌎 **SSR / Static Generation Support** – Functions to work with NuxtJS and other frameworks
5353

5454
## Install
5555

56+
### Vue
57+
5658
```bash
5759
npm install vue-notion
5860
```
5961

6062
### NuxtJS Module
63+
64+
Install as shown above and add `"vue-notion/nuxt"` to the `buildModules` array in `nuxt.config.js`.
65+
6166
```js
6267
// nuxt.config.js
63-
6468
export default {
6569
// ...
66-
buildModules: [
67-
'vue-notion/nuxt'
68-
]
69-
notion: {
70-
// additionals configuration
71-
}
72-
}
70+
buildModules: ["vue-notion/nuxt"],
71+
};
7372
```
7473

75-
## How To
74+
## Docs
75+
76+
<!-- todo: add # links to doc links -->
77+
78+
- `NotionRenderer`: [`docs/`](https://github.com/janniks/vue-notion/tree/main/docs)
79+
- Syntax Highlighting in Code Blocks (with Prism.js): [`docs/`](https://github.com/janniks/vue-notion/tree/main/docs)
80+
- Notion API: [`docs/`](https://github.com/janniks/vue-notion/tree/main/docs)
81+
- Nuxt: [`docs/`](https://github.com/janniks/vue-notion/tree/main/docs)
7682

77-
### Docs
83+
> Check out a full working demo at [vue-notion.now.sh](https://vue-notion.now.sh/)
84+
> The code for the demo is in [`example/`](https://github.com/janniks/vue-notion/tree/main/example).
7885
79-
> Check out a demo at [vue-notion.now.sh](https://vue-notion.now.sh/)
86+
## Examples
8087

81-
More information on the `NotionRenderer` specification, syntax-highlighting, the Notion API, and integration with Nuxt can be found at [`docs/`](https://github.com/janniks/vue-notion/tree/main/docs).
88+
These examples use a simple wrapper around the [`notion-api-worker`](https://github.com/splitbee/notion-api-worker).
89+
It is also possible to store a page received from the Notion API in `.json` and use it without the `async/await` part.
8290

8391
### Basic Example for Vue
8492

85-
This example is hosted at [vue-notion.now.sh/welcome](https://vue-notion.now.sh/welcome).
93+
This example is a part of [`example/`](https://github.com/janniks/vue-notion/tree/main/example) and is hosted at [vue-notion.now.sh/vue](https://vue-notion.now.sh/vue).
8694

8795
```vue
8896
<template>
@@ -107,12 +115,9 @@ export default {
107115
</style>
108116
```
109117

110-
The example above uses a simple wrapper around the [notion-api-worker](https://github.com/splitbee/notion-api-worker).
111-
It is also possible to store and use plain `.json` objects received from the Notion API.
118+
### Basic Example for NuxtJS
112119

113-
### Basic Example for Nuxt
114-
115-
This example is hosted at [vue-notion.now.sh/welcome](https://vue-notion.now.sh/welcome).
120+
This example is a part of [`example/`](https://github.com/janniks/vue-notion/tree/main/example) and is hosted at [vue-notion.now.sh/nuxt](https://vue-notion.now.sh/nuxt).
116121

117122
```vue
118123
<template>
@@ -123,28 +128,26 @@ This example is hosted at [vue-notion.now.sh/welcome](https://vue-notion.now.sh/
123128
export default {
124129
data: () => ({ blockMap: null }),
125130
async asyncData({ $notion }) {
126-
// use notion module to get Notion blocks from the API via a Notion pageId
127-
const blockMap = await $notion.getPageBlocks("8c1ab01960b049f6a282dda64a94afc7");
128-
129-
return { blockMap }
131+
// use Notion module to get Notion blocks from the API via a Notion pageId
132+
const blockMap = await $notion.getPageBlocks(
133+
"8c1ab01960b049f6a282dda64a94afc7"
134+
);
135+
return { blockMap };
130136
},
131137
};
138+
</script>
132139
133140
<style>
134141
@import "vue-notion/src/styles.css"; /* optional Notion-like styles */
135142
</style>
136143
```
137-
</script>
138-
139144

140-
> ⚠️ Use with caution.
145+
> ⚠️ Use with caution!
141146
> The `getPageBlocks` and `getPageTable` are based on the private Notion API.
142-
> We can not gurantee it will stay stable.
147+
> We can NOT guarantee that it will stay stable.
143148
> The private API is warpped by [notion-api-worker](https://github.com/splitbee/notion-api-worker).
144149
> If you use these methods a lot, please consider hosting you own instance, as described in [`docs#notion-api`](https://github.com/janniks/vue-notion/tree/main/docs#notion-api).
145150
146-
A [full working example using Nuxt and static generation](https://vue-notion.now.sh/) can be found inside the `example` directory.
147-
148151
## Roadmap
149152

150153
[Add issues](https://github.com/janniks/vue-notion/issues/new), request features and upvote [block types](https://github.com/janniks/vue-notion/issues?q=is%3Aissue+is%3Aopen+label%3Ablock) that you want to see next!
@@ -160,42 +163,45 @@ List of pages that are using this library.
160163

161164
Most common block types are supported. We happily accept pull requests to add support for the missing blocks.
162165

163-
| Block Type | Supported | Notes |
164-
| ----------------- | -------------- | ------------------------ |
165-
| Text | ✅ Yes | |
166-
| Heading | ✅ Yes | |
167-
| Image | ✅ Yes | |
168-
| Image Caption | ✅ Yes | |
169-
| Bulleted List | ✅ Yes | |
170-
| Numbered List | ✅ Yes | |
171-
| Quote | ✅ Yes | |
172-
| Callout | ✅ Yes | |
173-
| Column | ✅ Yes | |
174-
| iframe | ✅ Yes | |
175-
| Video | ✅ Yes | Only embedded videos |
176-
| Divider | ✅ Yes | |
177-
| Link | ✅ Yes | |
178-
| Code | ✅ Yes | |
179-
| Web Bookmark | ✅ Yes | |
180-
| Toggle List | ✅ Yes | |
181-
| Page Links | ✅ Yes | |
182-
| Cover | ✅ Yes | Enable with `fullPage` |
183-
| Databases | ❌ Not planned | |
184-
| Checkbox | ❌ Not planned | |
185-
| Table Of Contents | ❌ Not planned | |
186-
187-
Please, feel free to [open an issue](https://github.com/janniks/vue-notion/issues/new) if you notice any missing blocks or anything wrong with existing blocks.
166+
| Block Type | Supported | Notes |
167+
| ----------------- | -------------- | ---------------------- |
168+
| Text | ✅ Yes | |
169+
| Heading | ✅ Yes | |
170+
| Image | ✅ Yes | |
171+
| Image Caption | ✅ Yes | |
172+
| Bulleted List | ✅ Yes | |
173+
| Numbered List | ✅ Yes | |
174+
| Quote | ✅ Yes | |
175+
| Callout | ✅ Yes | |
176+
| Column | ✅ Yes | |
177+
| iframe | ✅ Yes | |
178+
| Video | ✅ Yes | Only embedded videos |
179+
| Divider | ✅ Yes | |
180+
| Link | ✅ Yes | |
181+
| Code | ✅ Yes | |
182+
| Web Bookmark | ✅ Yes | |
183+
| Toggle List | ✅ Yes | |
184+
| Page Links | ✅ Yes | |
185+
| Cover | ✅ Yes | Enable with `fullPage` |
186+
| Equations | ✅ Planned | |
187+
| Databases | ❌ Not planned | |
188+
| Checkbox | ❌ Not planned | |
189+
| Table Of Contents | ❌ Not planned | |
190+
191+
Please, feel free to [open an issue](https://github.com/janniks/vue-notion/issues/new) if you notice any important blocks missing or anything wrong with existing blocks.
188192

189193
## Credits
190194

191195
- [Jannik Siebert](https://twitter.com/jnnksbrt) – vue-notion Code
192196
- [Dominik Sobe](https://twitter.com/sobedominik) – vue-notion Inspiration, Debugging
197+
- [vue-notion Contributors 💕](https://github.com/janniks/vue-notion/graphs/contributors)
193198
- [Tobias Lins](https://tobi.sh) – react-notion Idea, Code
194199
- [Timo Lins](https://timo.sh) – react-notion Code, Documentation
195200
- [samwightt](https://github.com/samwightt) – react-notion Inspiration & API Typings
196-
- [vue-notion Contributors 💕](https://github.com/janniks/vue-notion/graphs/contributors)
197201
- [react-notion Contributors 💕](https://github.com/splitbee/react-notion/graphs/contributors)
198202

203+
- Big thanks to [NuxtJS](https://nuxtjs.org) for being awesome!
204+
199205
## License ⚖️
200206

201207
MIT © [Jannik Siebert](https://twitter.com/jnnksbrt)

docs/README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ mapPageUrl(pageId = "") {
5757
– are used to override links to other Notion pages with custom Vue components.
5858
`pageLinkOptions` is an `Object` that requires a `component` and a `href` parameter.
5959

60-
e.g. to use `NuxtLink` components instead of HTML `a` elements
60+
e.g., to use `NuxtLink` components instead of HTML `a` elements
6161

6262
```js
6363
pageLinkOptions: {
@@ -114,7 +114,7 @@ const pageTable = await getPageTable("PAGE_ID", "ENDPOINT_URL");
114114

115115
> Feel free to open an issue if something is unclear or additional documentation is needed...
116116
117-
## Nuxt – Server-Side Rendering & Static Site Generation
117+
## NuxtJS – Server-Side Rendering & Static Site Generation
118118

119119
> For a running project check out the extensive example at [example/](/example).
120120
@@ -123,16 +123,17 @@ const pageTable = await getPageTable("PAGE_ID", "ENDPOINT_URL");
123123
There are a few required steps to allow Nuxt to work with vue-notion
124124

125125
- Install vue-notion as a dependency to your Nuxt project – `npm install vue-notion`
126-
- Add `"vue-notion"` to the `build.transpile` array in `nuxt.config.js`.
126+
- Add `"vue-notion/nuxt"` to the `buildModules` array in `nuxt.config.js`.
127127

128128
```js
129-
build: {
130-
transpile: ["vue-notion"];
131-
}
129+
// nuxt.config.js
130+
export default {
131+
// ...
132+
buildModules: ["vue-notion/nuxt"],
133+
};
132134
```
133135

134-
- Import the `NotionRenderer` in any component you want to use vue-notion in – `import { NotionRenderer } from "vue-notion"`
135-
- Voila, you can now use vue-notion as shown in the examples.
136+
- Voila, you can now use vue-notion (i.e., the `NotionRenderer` component and the Notion API methods via NuxtJS `$notion`) as shown in the examples.
136137

137138
### Static Pages
138139

example/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package-lock.json
2+
yarn.lock
23

34
# Created by .ignore support plugin (hsz.mobi)
45
### Node template

example/nuxt.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,5 @@ export default {
2020
components: true,
2121

2222
// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
23-
buildModules: [
24-
'vue-notion/nuxt'
25-
]
23+
buildModules: ["vue-notion/nuxt"],
2624
};

example/pages/nuxt.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<NotionRenderer :blockMap="blockMap" fullPage />
3+
</template>
4+
5+
<script>
6+
export default {
7+
data: () => ({ blockMap: null }),
8+
async asyncData({ $notion }) {
9+
// use Notion module to get Notion blocks from the API via a Notion pageId
10+
const blockMap = await $notion.getPageBlocks(
11+
"8c1ab01960b049f6a282dda64a94afc7"
12+
);
13+
return { blockMap };
14+
},
15+
};
16+
</script>
17+
18+
<style>
19+
@import "vue-notion/src/styles.css"; /* optional Notion-like styles */
20+
</style>
File renamed without changes.

nuxt/index.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
import path from 'path'
2-
import defu from 'defu'
1+
import path from "path";
2+
import defu from "defu";
33

4-
const defaultOptions = {}
4+
const defaultOptions = {};
55

6-
module.exports = function (moduleOptions) {
7-
const options = defu({
8-
...this.options.notion,
9-
...moduleOptions
10-
}, defaultOptions)
6+
module.exports = function(moduleOptions) {
7+
const options = defu(
8+
{
9+
...this.options.notion,
10+
...moduleOptions,
11+
},
12+
defaultOptions
13+
);
1114

12-
this.nuxt.hook('build:before', () => {
15+
this.nuxt.hook("build:before", () => {
1316
// Enable transpilation for `vue-notion`
14-
this.options.build.transpile.push('vue-notion')
17+
this.options.build.transpile.push("vue-notion");
1518

1619
this.addPlugin({
17-
src: path.resolve(__dirname, 'plugin.js'),
18-
fileName: 'vue-notion.js',
19-
options
20-
})
21-
})
22-
}
20+
src: path.resolve(__dirname, "plugin.js"),
21+
fileName: "vue-notion.js",
22+
options,
23+
});
24+
});
25+
};
2326

24-
module.exports.meta = require('../package.json')
27+
module.exports.meta = require("../package.json");

nuxt/plugin.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import Vue from 'vue'
2-
import VueNotion from 'vue-notion'
3-
import { getPageBlocks, getPageTable } from 'vue-notion'
1+
import Vue from "vue";
2+
import VueNotion from "vue-notion";
3+
import { getPageBlocks, getPageTable } from "vue-notion";
44

5-
Vue.use(VueNotion)
5+
Vue.use(VueNotion);
66

77
export default (_, inject) => {
8-
const notion = { getPageBlocks, getPageTable }
9-
inject('notion', notion)
10-
}
8+
const notion = { getPageBlocks, getPageTable };
9+
inject("notion", notion);
10+
};

0 commit comments

Comments
 (0)