Skip to content

Commit 218afa8

Browse files
committed
add google drive
1 parent da705f6 commit 218afa8

File tree

4 files changed

+100
-1
lines changed

4 files changed

+100
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
},
4949
"dependencies": {
5050
"@nuxt/kit": "^3.0.0-rc.1",
51+
"@vueuse/core": "^8.7.5",
5152
"fragment-for-vue": "^1.0.1",
5253
"katex": "^0.15.1",
5354
"pathe": "^0.2.0",

src/blocks/helpers/google-drive.vue

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<script setup lang="ts">
2+
import { useNotionBlock, defineNotionProps } from "@/lib/blockable"
3+
import { computed } from "vue"
4+
import { useTimeAgo } from "@vueuse/core"
5+
6+
const props = defineProps({ ...defineNotionProps })
7+
//@ts-ignore
8+
const { format, block, hasPageLinkOptions, pageLinkProps } = useNotionBlock(props)
9+
10+
const properties = computed(() => format.value.drive_properties)
11+
12+
const constructThumbnail = (src?: string) => {
13+
if (!src) return
14+
const q = new URLSearchParams({
15+
table: "block",
16+
id: block.value.value.id,
17+
cache: "v2",
18+
})
19+
return "https://www.notion.so/image/" + encodeURIComponent(src) + "?" + q
20+
}
21+
const constructDomain = (src?: string) => {
22+
if (!src) return
23+
return new URL(src).hostname
24+
}
25+
</script>
26+
27+
<script lang="ts">
28+
export default {
29+
name: "NotionBookmark",
30+
}
31+
</script>
32+
33+
<template>
34+
<div class="notion-google-drive">
35+
<component
36+
v-if="hasPageLinkOptions"
37+
class="notion-google-drive-link"
38+
v-bind="pageLinkProps(block.value.id)"
39+
:is="props.pageLinkOptions?.component"
40+
>
41+
<div class="notion-google-drive-preview">
42+
<img :src="constructThumbnail(properties.thumbnail)" :alt="properties.title" />
43+
</div>
44+
45+
<div className="notion-google-drive-body">
46+
<div className="notion-google-drive-body-title">
47+
{{ properties.title }}
48+
</div>
49+
50+
<div className="notion-google-drive-body-modified-time">
51+
Last modified
52+
{{ properties.user_name ? `by ${properties.user_name} ` : "" }}
53+
{{ useTimeAgo(properties.modified_time).value }}
54+
</div>
55+
56+
<div className="notion-google-drive-body-source">
57+
<div
58+
className="notion-google-drive-body-source-icon"
59+
:style="{ backgroundImage: 'url(' + properties.icon + ')' }"
60+
/>
61+
<div className="notion-google-drive-body-source-domain">{{ constructDomain(properties.url) }}</div>
62+
</div>
63+
</div>
64+
</component>
65+
</div>
66+
</template>

src/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ svg.notion-page-icon {
17231723
border-radius: 3px;
17241724

17251725
user-select: none;
1726-
transition: background 20ms ease-in 0s;
1726+
transition: background 100ms ease-in 0s;
17271727
cursor: pointer;
17281728
}
17291729

yarn.lock

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,11 @@
377377
dependencies:
378378
"@types/node" "*"
379379

380+
"@types/web-bluetooth@^0.0.14":
381+
version "0.0.14"
382+
resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.14.tgz#94e175b53623384bff1f354cdb3197a8d63cdbe5"
383+
integrity sha512-5d2RhCard1nQUC3aHcq/gHzWYO6K0WJmAbjO7mQJgCQKtZpgXxv1rOM6O/dBDhDYYVutk1sciOgNSe+5YyfM8A==
384+
380385
"@vitejs/plugin-vue@^2.0.0":
381386
version "2.3.3"
382387
resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-2.3.3.tgz#fbf80cc039b82ac21a1acb0f0478de8f61fbf600"
@@ -576,6 +581,28 @@
576581
resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.2.33.tgz#69a8c99ceb37c1b031d5cc4aec2ff1dc77e1161e"
577582
integrity sha512-UBc1Pg1T3yZ97vsA2ueER0F6GbJebLHYlEi4ou1H5YL4KWvMOOWwpYo9/QpWq93wxKG6Wo13IY74Hcn/f7c7Bg==
578583

584+
"@vueuse/core@^8.7.5":
585+
version "8.7.5"
586+
resolved "https://registry.yarnpkg.com/@vueuse/core/-/core-8.7.5.tgz#e74a888251ea11a9d432068ce18cbdfc4f810251"
587+
integrity sha512-tqgzeZGoZcXzoit4kOGLWJibDMLp0vdm6ZO41SSUQhkhtrPhAg6dbIEPiahhUu6sZAmSYvVrZgEr5aKD51nrLA==
588+
dependencies:
589+
"@types/web-bluetooth" "^0.0.14"
590+
"@vueuse/metadata" "8.7.5"
591+
"@vueuse/shared" "8.7.5"
592+
vue-demi "*"
593+
594+
595+
version "8.7.5"
596+
resolved "https://registry.yarnpkg.com/@vueuse/metadata/-/metadata-8.7.5.tgz#c7f2b21d873d1604a8860ed9c5728d8f3295f00a"
597+
integrity sha512-emJZKRQSaEnVqmlu39NpNp8iaW+bPC2kWykWoWOZMSlO/0QVEmO/rt8A5VhOEJTKLX3vwTevqbiRy9WJRwVOQg==
598+
599+
600+
version "8.7.5"
601+
resolved "https://registry.yarnpkg.com/@vueuse/shared/-/shared-8.7.5.tgz#06fb08f6f8fc9e90be9d1e033fa443de927172b0"
602+
integrity sha512-THXPvMBFmg6Gf6AwRn/EdTh2mhqwjGsB2Yfp374LNQSQVKRHtnJ0I42bsZTn7nuEliBxqUrGQm/lN6qUHmhJLw==
603+
dependencies:
604+
vue-demi "*"
605+
579606
acorn@^8.7.0:
580607
version "8.7.0"
581608
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf"
@@ -2412,6 +2439,11 @@ vite@^2.9.7:
24122439
optionalDependencies:
24132440
fsevents "~2.3.2"
24142441

2442+
vue-demi@*:
2443+
version "0.13.2"
2444+
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.13.2.tgz#f6081c2feb5b698549729a81683ce029b8da289e"
2445+
integrity sha512-41ukrclEbMddAyP7PvxMSYqnOSzPV6r7GNnyTSKSCNTaz19GehxmTiXyP9kwHSUv2+Dr6hHqiUiF7L1VAw2KdQ==
2446+
24152447
vue-router@4:
24162448
version "4.0.14"
24172449
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.0.14.tgz#ce2028c1c5c33e30c7287950c973f397fce1bd65"

0 commit comments

Comments
 (0)