@nei7/nuxt-notion 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +84 -0
  2. package/dist/module.d.mts +9 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +32 -0
  5. package/dist/runtime/components/BulletedListItem.d.vue.ts +7 -0
  6. package/dist/runtime/components/BulletedListItem.vue +12 -0
  7. package/dist/runtime/components/BulletedListItem.vue.d.ts +7 -0
  8. package/dist/runtime/components/Callout.d.vue.ts +7 -0
  9. package/dist/runtime/components/Callout.vue +40 -0
  10. package/dist/runtime/components/Callout.vue.d.ts +7 -0
  11. package/dist/runtime/components/Code.d.vue.ts +7 -0
  12. package/dist/runtime/components/Code.vue +22 -0
  13. package/dist/runtime/components/Code.vue.d.ts +7 -0
  14. package/dist/runtime/components/Divider.d.vue.ts +7 -0
  15. package/dist/runtime/components/Divider.vue +9 -0
  16. package/dist/runtime/components/Divider.vue.d.ts +7 -0
  17. package/dist/runtime/components/Embed.d.vue.ts +7 -0
  18. package/dist/runtime/components/Embed.vue +74 -0
  19. package/dist/runtime/components/Embed.vue.d.ts +7 -0
  20. package/dist/runtime/components/Equation.d.vue.ts +7 -0
  21. package/dist/runtime/components/Equation.vue +13 -0
  22. package/dist/runtime/components/Equation.vue.d.ts +7 -0
  23. package/dist/runtime/components/File.d.vue.ts +7 -0
  24. package/dist/runtime/components/File.vue +21 -0
  25. package/dist/runtime/components/File.vue.d.ts +7 -0
  26. package/dist/runtime/components/Header.d.vue.ts +7 -0
  27. package/dist/runtime/components/Header.vue +24 -0
  28. package/dist/runtime/components/Header.vue.d.ts +7 -0
  29. package/dist/runtime/components/Image.d.vue.ts +7 -0
  30. package/dist/runtime/components/Image.vue +33 -0
  31. package/dist/runtime/components/Image.vue.d.ts +7 -0
  32. package/dist/runtime/components/ListRenderer.d.vue.ts +8 -0
  33. package/dist/runtime/components/ListRenderer.vue +50 -0
  34. package/dist/runtime/components/ListRenderer.vue.d.ts +8 -0
  35. package/dist/runtime/components/MathFormula.d.vue.ts +9 -0
  36. package/dist/runtime/components/MathFormula.vue +22 -0
  37. package/dist/runtime/components/MathFormula.vue.d.ts +9 -0
  38. package/dist/runtime/components/NumberedListItem.d.vue.ts +7 -0
  39. package/dist/runtime/components/NumberedListItem.vue +12 -0
  40. package/dist/runtime/components/NumberedListItem.vue.d.ts +7 -0
  41. package/dist/runtime/components/Paragraph.d.vue.ts +7 -0
  42. package/dist/runtime/components/Paragraph.vue +19 -0
  43. package/dist/runtime/components/Paragraph.vue.d.ts +7 -0
  44. package/dist/runtime/components/Quote.d.vue.ts +7 -0
  45. package/dist/runtime/components/Quote.vue +17 -0
  46. package/dist/runtime/components/Quote.vue.d.ts +7 -0
  47. package/dist/runtime/components/Renderer.d.vue.ts +7 -0
  48. package/dist/runtime/components/Renderer.vue +111 -0
  49. package/dist/runtime/components/Renderer.vue.d.ts +7 -0
  50. package/dist/runtime/components/Text.d.vue.ts +7 -0
  51. package/dist/runtime/components/Text.vue +20 -0
  52. package/dist/runtime/components/Text.vue.d.ts +7 -0
  53. package/dist/runtime/components/TextRenderer.d.vue.ts +7 -0
  54. package/dist/runtime/components/TextRenderer.vue +14 -0
  55. package/dist/runtime/components/TextRenderer.vue.d.ts +7 -0
  56. package/dist/runtime/components/TodoListItem.d.vue.ts +7 -0
  57. package/dist/runtime/components/TodoListItem.vue +23 -0
  58. package/dist/runtime/components/TodoListItem.vue.d.ts +7 -0
  59. package/dist/runtime/components/Video.d.vue.ts +7 -0
  60. package/dist/runtime/components/Video.vue +39 -0
  61. package/dist/runtime/components/Video.vue.d.ts +7 -0
  62. package/dist/runtime/components/WebBookmark.d.vue.ts +7 -0
  63. package/dist/runtime/components/WebBookmark.vue +58 -0
  64. package/dist/runtime/components/WebBookmark.vue.d.ts +7 -0
  65. package/dist/runtime/composables/notion.d.ts +4 -0
  66. package/dist/runtime/composables/notion.js +9 -0
  67. package/dist/runtime/composables/useNotionClient.d.ts +2 -0
  68. package/dist/runtime/composables/useNotionClient.js +14 -0
  69. package/dist/runtime/server/api/_notion/blocks.get.d.ts +2 -0
  70. package/dist/runtime/server/api/_notion/blocks.get.js +14 -0
  71. package/dist/runtime/server/api/_notion/link-meta.get.d.ts +2 -0
  72. package/dist/runtime/server/api/_notion/link-meta.get.js +44 -0
  73. package/dist/runtime/server/api/_notion/page.get.d.ts +2 -0
  74. package/dist/runtime/server/api/_notion/page.get.js +13 -0
  75. package/dist/runtime/server/api/_notion/query-database.get.d.ts +2 -0
  76. package/dist/runtime/server/api/_notion/query-database.get.js +15 -0
  77. package/dist/runtime/server/tsconfig.json +3 -0
  78. package/dist/runtime/types/index.d.ts +14 -0
  79. package/dist/runtime/types/index.js +0 -0
  80. package/dist/runtime/types/notion.d.ts +11 -0
  81. package/dist/runtime/types/notion.js +0 -0
  82. package/dist/runtime/utils/index.d.ts +7 -0
  83. package/dist/runtime/utils/index.js +41 -0
  84. package/dist/types.d.mts +3 -0
  85. package/package.json +68 -0
@@ -0,0 +1,22 @@
1
+ <script setup>
2
+ import katex from "katex";
3
+ import { computed } from "vue";
4
+ const props = defineProps({
5
+ displayMode: { type: Boolean, required: false, default: false },
6
+ expression: { type: String, required: true }
7
+ });
8
+ const html = computed(() => {
9
+ try {
10
+ return katex.renderToString(props.expression, {
11
+ displayMode: props.displayMode,
12
+ throwOnError: false
13
+ });
14
+ } catch {
15
+ return props.expression;
16
+ }
17
+ });
18
+ </script>
19
+
20
+ <template>
21
+ <span v-html="html" />
22
+ </template>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ displayMode?: boolean;
3
+ expression: string;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
+ displayMode: boolean;
7
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { NumberedListItemBlockObjectResponse } from '@notionhq/client';
2
+ type __VLS_Props = {
3
+ block: NumberedListItemBlockObjectResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,12 @@
1
+ <script setup>
2
+ import TextRenderer from "./TextRenderer.vue";
3
+ defineProps({
4
+ block: { type: Object, required: true }
5
+ });
6
+ </script>
7
+
8
+ <template>
9
+ <li>
10
+ <TextRenderer :text="block.numbered_list_item.rich_text" />
11
+ </li>
12
+ </template>
@@ -0,0 +1,7 @@
1
+ import type { NumberedListItemBlockObjectResponse } from '@notionhq/client';
2
+ type __VLS_Props = {
3
+ block: NumberedListItemBlockObjectResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { ParagraphBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints';
2
+ type __VLS_Props = {
3
+ block: ParagraphBlockObjectResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,19 @@
1
+ <script setup>
2
+ import TextRenderer from "./TextRenderer.vue";
3
+ defineProps({
4
+ block: { type: Object, required: true }
5
+ });
6
+ </script>
7
+
8
+ <template>
9
+ <p
10
+ v-if="block.paragraph.rich_text.length > 0"
11
+ class="leading-loose mb-6 text-slate-700"
12
+ >
13
+ <TextRenderer :text="block.paragraph.rich_text" />
14
+ </p>
15
+ <p
16
+ v-else
17
+ class="h-px mb-6"
18
+ />
19
+ </template>
@@ -0,0 +1,7 @@
1
+ import type { ParagraphBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints';
2
+ type __VLS_Props = {
3
+ block: ParagraphBlockObjectResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { QuoteBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints';
2
+ type __VLS_Props = {
3
+ block: QuoteBlockObjectResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,17 @@
1
+ <script setup>
2
+ import TextRenderer from "./TextRenderer.vue";
3
+ import { notionColorToCss } from "../utils";
4
+ const { block } = defineProps({
5
+ block: { type: Object, required: true }
6
+ });
7
+ const color = notionColorToCss(block.quote.color);
8
+ </script>
9
+
10
+ <template>
11
+ <blockquote
12
+ :class="color"
13
+ class="p-3 my-4 border-s-4 italic after:content-[close-quote] before:content-[open-quote]"
14
+ >
15
+ <TextRenderer :text="block.quote.rich_text" />
16
+ </blockquote>
17
+ </template>
@@ -0,0 +1,7 @@
1
+ import type { QuoteBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints';
2
+ type __VLS_Props = {
3
+ block: QuoteBlockObjectResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { AnyNotionBlock } from '../types/notion.js';
2
+ type __VLS_Props = {
3
+ blocks: AnyNotionBlock[];
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,111 @@
1
+ <script setup>
2
+ import { isFullBlock } from "@notionhq/client";
3
+ import { isNotionBlockType } from "../utils";
4
+ import { computed } from "vue";
5
+ import Header from "./Header.vue";
6
+ import Paragraph from "./Paragraph.vue";
7
+ import Image from "./Image.vue";
8
+ import Code from "./Code.vue";
9
+ import Callout from "./Callout.vue";
10
+ import Quote from "./Quote.vue";
11
+ import ListRenderer from "./ListRenderer.vue";
12
+ import Divider from "./Divider.vue";
13
+ import Video from "./Video.vue";
14
+ import File from "./File.vue";
15
+ import Embed from "./Embed.vue";
16
+ import WebBookmark from "./WebBookmark.vue";
17
+ import Equation from "./Equation.vue";
18
+ const props = defineProps({
19
+ blocks: { type: Array, required: true }
20
+ });
21
+ var RenderBlockType = /* @__PURE__ */ ((RenderBlockType2) => {
22
+ RenderBlockType2["Block"] = "block";
23
+ RenderBlockType2["List"] = "list";
24
+ return RenderBlockType2;
25
+ })(RenderBlockType || {});
26
+ const renderableBlocks = computed(() => {
27
+ const result = [];
28
+ for (const block of props.blocks) {
29
+ if (!isFullBlock(block)) continue;
30
+ const isListBlock = isNotionBlockType(block, "bulleted_list_item", "numbered_list_item", "to_do");
31
+ const lastItem = result[result.length - 1];
32
+ if (isListBlock && lastItem?.type === "list" /* List */ && lastItem.listType === block.type) {
33
+ lastItem.items.push(block);
34
+ } else if (isListBlock) {
35
+ result.push({
36
+ type: "list" /* List */,
37
+ listType: block.type,
38
+ items: [block]
39
+ });
40
+ } else {
41
+ result.push({ type: "block" /* Block */, block });
42
+ }
43
+ }
44
+ return result;
45
+ });
46
+ </script>
47
+
48
+ <template>
49
+ <div class="">
50
+ <template
51
+ v-for="(renderBlock, idx) in renderableBlocks"
52
+ :key="idx"
53
+ >
54
+ <template v-if="renderBlock.type === RenderBlockType.Block">
55
+ <Header
56
+ v-if="isNotionBlockType(renderBlock.block, 'heading_1', 'heading_2', 'heading_3')"
57
+ :block="renderBlock.block"
58
+ />
59
+ <Paragraph
60
+ v-else-if="isNotionBlockType(renderBlock.block, 'paragraph')"
61
+ :block="renderBlock.block"
62
+ />
63
+ <Image
64
+ v-else-if="isNotionBlockType(renderBlock.block, 'image')"
65
+ :block="renderBlock.block"
66
+ />
67
+ <Code
68
+ v-else-if="isNotionBlockType(renderBlock.block, 'code')"
69
+ :block="renderBlock.block"
70
+ />
71
+ <Callout
72
+ v-else-if="isNotionBlockType(renderBlock.block, 'callout')"
73
+ :block="renderBlock.block"
74
+ />
75
+ <Quote
76
+ v-else-if="isNotionBlockType(renderBlock.block, 'quote')"
77
+ :block="renderBlock.block"
78
+ />
79
+ <Divider
80
+ v-else-if="isNotionBlockType(renderBlock.block, 'divider')"
81
+ :block="renderBlock.block"
82
+ />
83
+ <Video
84
+ v-else-if="isNotionBlockType(renderBlock.block, 'video')"
85
+ :block="renderBlock.block"
86
+ />
87
+ <File
88
+ v-else-if="isNotionBlockType(renderBlock.block, 'file')"
89
+ :block="renderBlock.block"
90
+ />
91
+ <Embed
92
+ v-else-if="isNotionBlockType(renderBlock.block, 'embed')"
93
+ :embed="renderBlock.block"
94
+ />
95
+ <WebBookmark
96
+ v-else-if="isNotionBlockType(renderBlock.block, 'bookmark')"
97
+ :block="renderBlock.block"
98
+ />
99
+ <Equation
100
+ v-else-if="isNotionBlockType(renderBlock.block, 'equation')"
101
+ :block="renderBlock.block"
102
+ />
103
+ </template>
104
+ <ListRenderer
105
+ v-else-if="renderBlock.type === RenderBlockType.List"
106
+ :blocks="renderBlock.items"
107
+ :type="renderBlock.listType"
108
+ />
109
+ </template>
110
+ </div>
111
+ </template>
@@ -0,0 +1,7 @@
1
+ import type { AnyNotionBlock } from '../types/notion.js';
2
+ type __VLS_Props = {
3
+ blocks: AnyNotionBlock[];
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { RichTextItemResponse } from '@notionhq/client/build/src/api-endpoints';
2
+ type __VLS_Props = {
3
+ text: RichTextItemResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,20 @@
1
+ <script setup>
2
+ import { notionAnnotationsToCss } from "../utils";
3
+ import MathFormula from "./MathFormula.vue";
4
+ defineProps({
5
+ text: { type: Object, required: true }
6
+ });
7
+ </script>
8
+
9
+ <template>
10
+ <span
11
+ v-if="text.type === 'text'"
12
+ :class="notionAnnotationsToCss(text.annotations)"
13
+ >
14
+ {{ text.plain_text }}
15
+ </span>
16
+ <MathFormula
17
+ v-else-if="text.type === 'equation'"
18
+ :expression="text.equation.expression"
19
+ />
20
+ </template>
@@ -0,0 +1,7 @@
1
+ import type { RichTextItemResponse } from '@notionhq/client/build/src/api-endpoints';
2
+ type __VLS_Props = {
3
+ text: RichTextItemResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { RichTextItemResponse } from '@notionhq/client/build/src/api-endpoints';
2
+ type __VLS_Props = {
3
+ text: RichTextItemResponse[];
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,14 @@
1
+ <script setup>
2
+ import Text from "./Text.vue";
3
+ defineProps({
4
+ text: { type: Array, required: true }
5
+ });
6
+ </script>
7
+
8
+ <template>
9
+ <Text
10
+ v-for="(t, i) in text"
11
+ :key="i"
12
+ :text="t"
13
+ />
14
+ </template>
@@ -0,0 +1,7 @@
1
+ import type { RichTextItemResponse } from '@notionhq/client/build/src/api-endpoints';
2
+ type __VLS_Props = {
3
+ text: RichTextItemResponse[];
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { ToDoBlockObjectResponse } from '@notionhq/client';
2
+ type __VLS_Props = {
3
+ block: ToDoBlockObjectResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,23 @@
1
+ <script setup>
2
+ import TextRenderer from "./TextRenderer.vue";
3
+ defineProps({
4
+ block: { type: Object, required: true }
5
+ });
6
+ </script>
7
+
8
+ <template>
9
+ <div class="flex items-center space-x-2">
10
+ <input
11
+ type="checkbox"
12
+ :value="block.to_do.checked"
13
+ disabled
14
+ >
15
+ <div
16
+ :class="{
17
+ 'line-through': block.to_do.checked
18
+ }"
19
+ >
20
+ <TextRenderer :text="block.to_do.rich_text" />
21
+ </div>
22
+ </div>
23
+ </template>
@@ -0,0 +1,7 @@
1
+ import type { ToDoBlockObjectResponse } from '@notionhq/client';
2
+ type __VLS_Props = {
3
+ block: ToDoBlockObjectResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { VideoBlockObjectResponse } from '@notionhq/client';
2
+ type __VLS_Props = {
3
+ block: VideoBlockObjectResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,39 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import TextRenderer from "./TextRenderer.vue";
4
+ import Embed from "./Embed.vue";
5
+ const props = defineProps({
6
+ block: { type: Object, required: true }
7
+ });
8
+ const videoUrl = computed(() => {
9
+ return (props.block.video.type === "external" ? props.block?.video?.external?.url : props.block?.video?.file?.url) || "";
10
+ });
11
+ const isExternalVideo = (block) => {
12
+ return block.video.type === "external";
13
+ };
14
+ </script>
15
+
16
+ <template>
17
+ <div
18
+ class="relative aspect-video"
19
+ >
20
+ <Embed
21
+ v-if="isExternalVideo(block)"
22
+ :embed="block"
23
+ />
24
+
25
+ <video
26
+ v-else
27
+ class="absolute inset-0 w-full h-full m-0!"
28
+
29
+ controls
30
+ >
31
+ <source
32
+ :src="videoUrl"
33
+ >
34
+ Your browser does not support the video tag.
35
+ </video>
36
+
37
+ <TextRenderer :text="block.video.caption" />
38
+ </div>
39
+ </template>
@@ -0,0 +1,7 @@
1
+ import type { VideoBlockObjectResponse } from '@notionhq/client';
2
+ type __VLS_Props = {
3
+ block: VideoBlockObjectResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { BookmarkBlockObjectResponse } from '@notionhq/client';
2
+ type __VLS_Props = {
3
+ block: BookmarkBlockObjectResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,58 @@
1
+ <script setup>
2
+ import { useLazyFetch } from "#app";
3
+ const props = defineProps({
4
+ block: { type: Object, required: true }
5
+ });
6
+ const { data: linkMetadata } = useLazyFetch("/api/_notion/link-meta", {
7
+ query: { url: props.block.bookmark.url },
8
+ server: false
9
+ });
10
+ </script>
11
+
12
+ <template>
13
+ <a
14
+ :href="linkMetadata?.url"
15
+ target="_blank"
16
+ class="group my-8 flex h-32 w-full overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm transition hover:border-slate-300 hover:bg-slate-50 hover:shadow-md dark:border-slate-700 dark:bg-slate-800 dark:hover:bg-slate-700/50"
17
+ >
18
+
19
+ <div class="flex flex-1 flex-col justify-center p-4">
20
+ <h3 class="font-bold text-slate-800 line-clamp-1 group-hover:text-indigo-600 dark:text-slate-100">
21
+ {{ linkMetadata?.title }}
22
+ </h3>
23
+ <p
24
+ v-if="linkMetadata?.success"
25
+ class="mt-1 text-sm text-slate-500 line-clamp-2 dark:text-slate-400"
26
+ >
27
+ {{ linkMetadata.description }}
28
+ </p>
29
+ <div class="mt-auto flex items-center gap-1 text-xs text-slate-400">
30
+ <svg
31
+ class="h-3 w-3"
32
+ fill="none"
33
+ viewBox="0 0 24 24"
34
+ stroke="currentColor"
35
+ >
36
+ <path
37
+ stroke-linecap="round"
38
+ stroke-linejoin="round"
39
+ stroke-width="2"
40
+ d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"
41
+ />
42
+ </svg>
43
+ <span>{{ linkMetadata?.url }}</span>
44
+ </div>
45
+ </div>
46
+
47
+ <div
48
+ v-if="linkMetadata?.success && linkMetadata.image"
49
+ class="hidden w-48 shrink-0 sm:block"
50
+ >
51
+ <img
52
+ :src="linkMetadata.image"
53
+ alt="Preview image"
54
+ class="h-full w-full object-cover transition group-hover:scale-105"
55
+ >
56
+ </div>
57
+ </a>
58
+ </template>
@@ -0,0 +1,7 @@
1
+ import type { BookmarkBlockObjectResponse } from '@notionhq/client';
2
+ type __VLS_Props = {
3
+ block: BookmarkBlockObjectResponse;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import type { GetPageParameters, GetPageResponse, ListBlockChildrenParameters, ListBlockChildrenResponse, QueryDataSourceParameters, QueryDataSourceResponse } from '@notionhq/client';
2
+ export declare const getNotionBlocks: (params: ListBlockChildrenParameters) => Promise<ListBlockChildrenResponse>;
3
+ export declare const queryNotionDatabase: (params: QueryDataSourceParameters) => Promise<QueryDataSourceResponse>;
4
+ export declare const getNotionPage: (params: GetPageParameters) => Promise<GetPageResponse>;
@@ -0,0 +1,9 @@
1
+ export const getNotionBlocks = (params) => {
2
+ return $fetch("/api/_notion/blocks", { query: params });
3
+ };
4
+ export const queryNotionDatabase = (params) => {
5
+ return $fetch("/api/_notion/query-database", { query: params });
6
+ };
7
+ export const getNotionPage = (params) => {
8
+ return $fetch("/api/_notion/page", { query: params });
9
+ };
@@ -0,0 +1,2 @@
1
+ import { Client } from '@notionhq/client';
2
+ export declare const useNotionClient: () => Client;
@@ -0,0 +1,14 @@
1
+ import { useRuntimeConfig } from "#imports";
2
+ import { Client } from "@notionhq/client";
3
+ let notionClient;
4
+ export const useNotionClient = () => {
5
+ if (notionClient) return notionClient;
6
+ if (import.meta.server) {
7
+ const config = useRuntimeConfig().nuxtNotion;
8
+ notionClient = new Client({
9
+ auth: config.notionApiKey
10
+ });
11
+ } else
12
+ notionClient = new Client();
13
+ return notionClient;
14
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("h3").EventHandler<Omit<import("h3").EventHandlerRequest, "body">, Promise<import("@notionhq/client").ListBlockChildrenResponse>>;
2
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { getValidatedQuery } from "h3";
2
+ import { useNotionClient } from "../../../composables/useNotionClient.js";
3
+ import { z } from "zod";
4
+ import { defineCachedEventHandler } from "nitropack/runtime";
5
+ const schema = z.object({
6
+ block_id: z.string(),
7
+ start_cursor: z.string().optional(),
8
+ page_size: z.number().optional()
9
+ });
10
+ export default defineCachedEventHandler(async (event) => {
11
+ const client = useNotionClient();
12
+ const query = await getValidatedQuery(event, schema.parse);
13
+ return client.blocks.children.list(query);
14
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,44 @@
1
+ import createMetascraper from "metascraper";
2
+ import metascraperTitle from "metascraper-title";
3
+ import metascraperDescription from "metascraper-description";
4
+ import metascraperImage from "metascraper-image";
5
+ import metascraperFavicon from "metascraper-logo-favicon";
6
+ import { getQuery, createError } from "h3";
7
+ import { defineCachedEventHandler } from "#imports";
8
+ const scraper = createMetascraper([
9
+ metascraperTitle(),
10
+ metascraperDescription(),
11
+ metascraperImage(),
12
+ metascraperFavicon()
13
+ ]);
14
+ export default defineCachedEventHandler(async (event) => {
15
+ const { url } = getQuery(event);
16
+ const targetUrl = url?.toString();
17
+ if (!targetUrl) {
18
+ throw createError({ statusCode: 400, message: `"url" is required` });
19
+ }
20
+ const title = targetUrl ? new URL(targetUrl).hostname : "Link";
21
+ try {
22
+ const html = await $fetch(targetUrl, {
23
+ headers: {
24
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
25
+ },
26
+ timeout: 5e3
27
+ });
28
+ const metadata = await scraper({ html, url: targetUrl });
29
+ return {
30
+ success: true,
31
+ title: metadata.title || title,
32
+ description: metadata.description,
33
+ image: metadata.image,
34
+ icon: metadata.logo,
35
+ url
36
+ };
37
+ } catch {
38
+ return {
39
+ success: false,
40
+ title,
41
+ url
42
+ };
43
+ }
44
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("h3").EventHandler<Omit<import("h3").EventHandlerRequest, "body">, Promise<import("@notionhq/client").GetPageResponse>>;
2
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { getValidatedQuery } from "h3";
2
+ import { useNotionClient } from "../../../composables/useNotionClient.js";
3
+ import { z } from "zod";
4
+ import { defineCachedEventHandler } from "nitropack/runtime";
5
+ const schema = z.object({
6
+ page_id: z.string(),
7
+ filter_properties: z.array(z.string())
8
+ });
9
+ export default defineCachedEventHandler(async (event) => {
10
+ const client = useNotionClient();
11
+ const query = await getValidatedQuery(event, schema.parse);
12
+ return client.pages.retrieve(query);
13
+ });