Skip to content

Commit 3d4cbfe

Browse files
authored
Merge pull request #35 from zernonia/add-unofficial-notion-client-package
update nuxt demo, add notion-client endpoint
2 parents 0d5c772 + 0f8f083 commit 3d4cbfe

File tree

7 files changed

+1681
-964
lines changed

7 files changed

+1681
-964
lines changed

demo/nuxt/app.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts"></script>
22

33
<template>
4-
<NuxtChild></NuxtChild>
4+
<NuxtPage></NuxtPage>
55
</template>
66

77
<style>

demo/nuxt/nuxt.config.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { defineNuxtConfig } from "nuxt"
2-
31
export default defineNuxtConfig({
4-
meta: {
5-
title: "Nuxt3 Notion",
6-
meta: [{ charset: "utf-8" }, { name: "viewport", content: "width=device-width, initial-scale=1" }],
7-
link: [{ rel: "icon", type: "image/png", href: "/logo.png" }],
2+
app: {
3+
head: {
4+
title: "Nuxt3 Notion",
5+
meta: [{ charset: "utf-8" }, { name: "viewport", content: "width=device-width, initial-scale=1" }],
6+
link: [{ rel: "icon", type: "image/png", href: "/logo.png" }],
7+
},
88
},
99
modules: [["vue3-notion/nuxt", { css: true }]],
10-
})
10+
});

demo/nuxt/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"start": "node .output/server/index.mjs"
1111
},
1212
"dependencies": {
13-
"nuxt": "^3.0.0-rc.3",
14-
"vue3-notion": "^0.1.35"
13+
"notion-client": "^6.15.6",
14+
"nuxt": "^3.0.0-rc.12",
15+
"vue3-notion": "^0.1.38"
1516
}
1617
}

demo/nuxt/pages/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
2-
const { $notion } = useNuxtApp()
3-
const { data } = await useAsyncData("notion-index", () => $notion.getPageBlocks("4b2dc28a5df74034a943f8c8e639066a"))
4-
const { mapPageUrl, pageLinkOptions } = useProps()
2+
const { $notion } = useNuxtApp();
3+
const { data } = await useAsyncData("notion-index", () => $notion.getPageBlocks("4b2dc28a5df74034a943f8c8e639066a"));
4+
const { mapPageUrl, pageLinkOptions } = useProps();
55
</script>
66

77
<template>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { NotionAPI } from "notion-client";
2+
3+
export default defineEventHandler(async (event) => {
4+
const pageId = event.context.params.pageId;
5+
6+
const api = new NotionAPI();
7+
const page = await api.getPage(pageId.toString());
8+
9+
return page;
10+
});

demo/nuxt/server/middleware/swr.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import type { IncomingMessage, ServerResponse } from "http"
2-
3-
export default (_req: IncomingMessage, res: ServerResponse, next: () => void) => {
4-
// cache for 2 mins (120 seconds)
5-
res.setHeader("Cache-Control", "s-maxage=120, stale-while-revalidate")
6-
next()
7-
}
1+
export default defineEventHandler((event) => {
2+
event.res.setHeader("Cache-Control", "s-maxage=120, stale-while-revalidate");
3+
});

demo/nuxt/yarn.lock

Lines changed: 1654 additions & 944 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)