File tree Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ const filtered = computed(() => {
31
31
return item
32
32
}
33
33
// filter headers
34
- const matchedHeaders = item .headers .map (h => h .text ).filter (matches )
34
+ const matchedHeaders = item .headers .filter (
35
+ ({ text , anchor }) => matches (text ) || matches (anchor )
36
+ )
35
37
return matchedHeaders .length
36
38
? { text: item .text , link: item .link , headers: matchedHeaders }
37
39
: null
Original file line number Diff line number Diff line change @@ -4,15 +4,17 @@ import fs from 'fs'
4
4
import path from 'path'
5
5
import { sidebar } from '../../.vitepress/config'
6
6
7
+ interface APIHeader {
8
+ anchor : string
9
+ text : string
10
+ }
11
+
7
12
export interface APIGroup {
8
13
text : string
9
14
items : {
10
15
text : string
11
16
link : string
12
- headers : {
13
- anchor : string
14
- text : string
15
- } [ ]
17
+ headers : APIHeader [ ]
16
18
} [ ]
17
19
}
18
20
@@ -37,10 +39,7 @@ export default {
37
39
const headersCache = new Map <
38
40
string ,
39
41
{
40
- headers : {
41
- anchor : string
42
- text : string
43
- } [ ]
42
+ headers : APIHeader [ ]
44
43
timestamp : number
45
44
}
46
45
> ( )
@@ -56,10 +55,7 @@ function parsePageHeaders(link: string) {
56
55
57
56
const src = fs . readFileSync ( fullPath , 'utf-8' )
58
57
const h2s = src . match ( / ^ # # [ ^ \n ] + / gm)
59
- let headers : {
60
- anchor : string
61
- text : string
62
- } [ ] = [ ]
58
+ let headers : APIHeader [ ] = [ ]
63
59
if ( h2s ) {
64
60
headers = h2s . map ( ( h ) => {
65
61
const text = h
You can’t perform that action at this time.
0 commit comments