-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathApiSection.vue
More file actions
94 lines (86 loc) · 2 KB
/
Copy pathApiSection.vue
File metadata and controls
94 lines (86 loc) · 2 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<script lang="ts">
export const kindForUrl = (url: string) => {
const kindRe = /\/api\/.+\/(.+)\//;
return kindRe.exec(url)?.[1]!;
};
export const kindMappings = {
functions: {
icon: 'i-lucide-code',
color: 'success',
label: 'Functions',
value: 'functions',
},
classes: {
icon: 'i-lucide-box',
color: 'info',
label: 'Classes',
value: 'classes',
},
variables: {
icon: 'i-lucide-key',
color: 'primary',
label: 'Variables',
value: 'variables',
},
enumerations: {
icon: 'i-lucide-list-check',
color: 'warning',
label: 'Enumerations',
value: 'enumerations',
},
interfaces: {
icon: 'i-lucide-layout-dashboard',
color: 'neutral',
label: 'Interfaces',
value: 'interfaces',
},
'type-aliases': {
icon: 'i-lucide-type',
color: 'error',
label: 'Type Aliases',
value: 'type-aliases',
},
}
export const urlToKind = (url: string) => {
return kindMappings[kindForUrl(url)];
}
</script>
<script setup lang="ts">
defineProps<{
items: any[];
}>();
const makePageLinks = (items: any[]) => {
return items.map((item: any) => {
const kind = urlToKind(item.link);
return {
label: item.text,
to: item.link.replace('.md', ''),
icon: kind?.icon,
color: kind?.color,
};
});
}
</script>
<template>
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 mt-8" v-show="items.length > 0">
<UButton v-for="item in makePageLinks(items)" :key="item.label" :to="item.to" :color="item.color" variant="soft"
:icon="item.icon" class="w-full min-w-0 justify-start" :ui="{ base: 'min-w-0', leadingIcon: 'shrink-0' }">
<span class="min-w-0 flex-1 truncate">
{{ item.label }}
</span>
</UButton>
</div>
</template>
<style scoped>
:deep(ul) {
list-style: none !important;
margin-left: 0 !important;
margin-right: 0 !important;
padding-left: 0 !important;
padding-right: 0 !important;
}
:deep(a) {
color: revert-layer !important;
text-decoration: none !important;
}
</style>