@@ -5,6 +5,22 @@ page: true
5
5
6
6
<script setup >
7
7
import apiIndex from ' ./index.json'
8
+ import { ref , computed } from ' vue'
9
+
10
+ const query = ref (' ' )
11
+
12
+ const filtered = computed (() => {
13
+ const q = query .value
14
+ return apiIndex .map (section => {
15
+ const items = section .items .map (({ text, link, headers }) => {
16
+ headers = headers .filter (h => {
17
+ return h .toLowerCase ().includes (q .toLowerCase ())
18
+ })
19
+ return headers .length ? { text, link, headers } : null
20
+ }).filter (i => i)
21
+ return items .length ? { text: section .text , items } : null
22
+ }).filter (i => i)
23
+ })
8
24
9
25
// same as vitepress' slugify logic
10
26
function slugify (text ) {
@@ -23,9 +39,12 @@ function slugify(text) {
23
39
</script >
24
40
25
41
<div id =" api-index " >
26
- <h1 >API Reference</h1 >
42
+ <div class =" header " >
43
+ <h1>API Reference</h1>
44
+ <input class="api-filter" placeholder="Filter" v-model="query">
45
+ </div >
27
46
28
- <div v-for =" section of apiIndex " class =" api-section " >
47
+ <div v-for =" section of filtered " class =" api-section " >
29
48
<h2>{{ section.text }}</h2>
30
49
<div class="api-groups">
31
50
<div v-for="item of section.items" class="api-group">
66
85
h2 {
67
86
font-size : 24px ;
68
87
color : var (--vt-c-text-1 );
69
- margin : 64 px 0 36 px ;
88
+ margin : 36 px 0 ;
70
89
transition : color 0.5s ;
71
90
padding-top : 36px ;
72
91
border-top : 1px solid var (--vt-c-divider-light );
80
99
transition : color 0.5s ;
81
100
}
82
101
102
+ .api-section {
103
+ margin-bottom : 64px ;
104
+ }
105
+
83
106
.api-groups a {
84
107
font-size : 15px ;
85
108
font-weight : 500 ;
@@ -106,12 +129,29 @@ h3 {
106
129
transition : background-color 0.5s ;
107
130
}
108
131
132
+ .header {
133
+ display : flex ;
134
+ align-items : center ;
135
+ justify-content : space-between ;
136
+ }
137
+
138
+ .api-filter {
139
+ border : 1px solid var (--vt-c-divider );
140
+ border-radius : 8px ;
141
+ padding : 6px 12px ;
142
+ }
143
+
144
+ .api-filter :focus {
145
+ border-color : var (--vt-c-green-light );
146
+ }
147
+
109
148
@media (max-width : 768px ) {
110
149
#api-index {
111
150
padding : 42px 24px ;
112
151
}
113
152
h1 {
114
153
font-size : 32px ;
154
+ margin-bottom : 24px ;
115
155
}
116
156
h2 {
117
157
font-size : 22px ;
121
161
.api-groups a {
122
162
font-size : 14px ;
123
163
}
164
+ .header {
165
+ display : block ;
166
+ }
124
167
}
125
168
126
169
@media (min-width : 768px ) {
0 commit comments