1
1
import { H3Event } from 'h3'
2
- import { ParsedContent , QueryBuilderWhere } from '../types'
2
+ import type { ParsedContent , QueryBuilderWhere } from '../types'
3
3
import { serverQueryContent } from '#content/server'
4
4
5
5
export async function serverSearchContent ( event : H3Event , filterQuery ?: QueryBuilderWhere ) : Promise < ParsedContent [ ] > {
@@ -41,8 +41,9 @@ export function splitPageIntoSections (page: ParsedContent, { ignoredTags }: { i
41
41
let previousHeadingLevel = 0
42
42
const titles = [ ]
43
43
for ( const item of page . body . children ) {
44
- if ( isHeading ( item . tag ) ) {
45
- const currentHeadingLevel : number = Number ( item . tag . match ( HEADING ) ?. [ 1 ] ) ?? 0
44
+ const tag = item . tag || ''
45
+ if ( isHeading ( tag ) ) {
46
+ const currentHeadingLevel : number = Number ( tag . match ( HEADING ) ?. [ 1 ] ) ?? 0
46
47
47
48
const title = extractTextFromAst ( item ) . trim ( )
48
49
@@ -58,7 +59,7 @@ export function splitPageIntoSections (page: ParsedContent, { ignoredTags }: { i
58
59
}
59
60
60
61
sections . push ( {
61
- id : `${ path } #${ item . props . id } ` ,
62
+ id : `${ path } #${ item . props ? .id } ` ,
62
63
title,
63
64
titles : [ ...titles ] ,
64
65
content : '' ,
@@ -72,7 +73,7 @@ export function splitPageIntoSections (page: ParsedContent, { ignoredTags }: { i
72
73
section += 1
73
74
}
74
75
75
- if ( ! isHeading ( item . tag ) ) {
76
+ if ( ! isHeading ( tag ) ) {
76
77
if ( ! sections [ section ] ) {
77
78
sections [ section ] = {
78
79
id : '' ,
0 commit comments