Skip to content

Commit

Permalink
Merge pull request #35 from zernonia/add-unofficial-notion-client-pac…
Browse files Browse the repository at this point in the history
…kage

update nuxt demo, add notion-client endpoint
  • Loading branch information
zernonia authored Nov 10, 2022
2 parents 0d5c772 + 0f8f083 commit 3d4cbfe
Show file tree
Hide file tree
Showing 7 changed files with 1,681 additions and 964 deletions.
2 changes: 1 addition & 1 deletion demo/nuxt/app.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts"></script>

<template>
<NuxtChild></NuxtChild>
<NuxtPage></NuxtPage>
</template>

<style>
Expand Down
14 changes: 7 additions & 7 deletions demo/nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineNuxtConfig } from "nuxt"

export default defineNuxtConfig({
meta: {
title: "Nuxt3 Notion",
meta: [{ charset: "utf-8" }, { name: "viewport", content: "width=device-width, initial-scale=1" }],
link: [{ rel: "icon", type: "image/png", href: "/logo.png" }],
app: {
head: {
title: "Nuxt3 Notion",
meta: [{ charset: "utf-8" }, { name: "viewport", content: "width=device-width, initial-scale=1" }],
link: [{ rel: "icon", type: "image/png", href: "/logo.png" }],
},
},
modules: [["vue3-notion/nuxt", { css: true }]],
})
});
5 changes: 3 additions & 2 deletions demo/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"start": "node .output/server/index.mjs"
},
"dependencies": {
"nuxt": "^3.0.0-rc.3",
"vue3-notion": "^0.1.35"
"notion-client": "^6.15.6",
"nuxt": "^3.0.0-rc.12",
"vue3-notion": "^0.1.38"
}
}
6 changes: 3 additions & 3 deletions demo/nuxt/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
const { $notion } = useNuxtApp()
const { data } = await useAsyncData("notion-index", () => $notion.getPageBlocks("4b2dc28a5df74034a943f8c8e639066a"))
const { mapPageUrl, pageLinkOptions } = useProps()
const { $notion } = useNuxtApp();
const { data } = await useAsyncData("notion-index", () => $notion.getPageBlocks("4b2dc28a5df74034a943f8c8e639066a"));
const { mapPageUrl, pageLinkOptions } = useProps();
</script>

<template>
Expand Down
10 changes: 10 additions & 0 deletions demo/nuxt/server/api/page/[pageId].ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NotionAPI } from "notion-client";

export default defineEventHandler(async (event) => {
const pageId = event.context.params.pageId;

const api = new NotionAPI();
const page = await api.getPage(pageId.toString());

return page;
});
10 changes: 3 additions & 7 deletions demo/nuxt/server/middleware/swr.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import type { IncomingMessage, ServerResponse } from "http"

export default (_req: IncomingMessage, res: ServerResponse, next: () => void) => {
// cache for 2 mins (120 seconds)
res.setHeader("Cache-Control", "s-maxage=120, stale-while-revalidate")
next()
}
export default defineEventHandler((event) => {
event.res.setHeader("Cache-Control", "s-maxage=120, stale-while-revalidate");
});
2,598 changes: 1,654 additions & 944 deletions demo/nuxt/yarn.lock

Large diffs are not rendered by default.

2 comments on commit 3d4cbfe

@vercel
Copy link

@vercel vercel bot commented on 3d4cbfe Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 3d4cbfe Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vue3-notion – ./demo/nuxt

vue3-notion.vercel.app
vue3-notion-zernonia.vercel.app
vue3-notion-git-master-zernonia.vercel.app

Please sign in to comment.