/
FunctionInfo.vue
61 lines (57 loc) · 1.77 KB
/
FunctionInfo.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<script setup lang="ts">
import { useTimeAgo } from '@vueuse/core'
import { computed } from 'vue'
import { functions } from '../../../../packages/metadata/metadata'
const props = defineProps<{ fn: string }>()
const info = computed(() => functions.find(i => i.name === props.fn))
const format = (ts: number) => ago(-1, 'day')
const lastUpdated = useTimeAgo(new Date(info.value?.lastUpdated || 0))
const link = computed(() => `/functions\#category=${encodeURIComponent(info.value.category)}`)
const getFunctionLink = (fn: string) => {
const info = functions.find(i => i.name === fn)
return info?.docs.replace(/https?:\/\/vueuse\.org\//g, '/')
}
</script>
<template>
<div class="grid grid-cols-[100px_auto] gap-2 text-sm -mt-2 mb-8 items-center">
<div opacity="50">
Category
</div>
<div><a :href="link">{{ info.category }}</a></div>
<template v-if="info.package !== 'core' && info.package !== 'shared'">
<div opacity="50">
Package
</div>
<div><code>@vueuse/{{ info.package }}</code></div>
</template>
<template v-if="info.lastUpdated">
<div opacity="50">
Last Changed
</div>
<div>{{ lastUpdated }}</div>
</template>
<template v-if="info.alias?.length">
<div opacity="50">
Alias
</div>
<div flex="~ gap-1">
<code v-for="a, idx of info.alias" :key="idx" class="!py-0">{{ a }}</code>
</div>
</template>
<template v-if="info.related?.length">
<div opacity="50">
Related
</div>
<div flex="~ gap-1">
<a
v-for="name, idx of info.related"
:key="idx"
class="!py-0"
:href="getFunctionLink(name)"
>
<code>{{ name }}</code>
</a>
</div>
</template>
</div>
</template>