@brillout/docpress 0.11.4 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -23,10 +23,28 @@ export function Snippet<TItem extends StoredDocSearchHit>({
|
|
|
23
23
|
tagName = 'span',
|
|
24
24
|
...rest
|
|
25
25
|
}: SnippetProps<TItem>) {
|
|
26
|
+
let title = ''
|
|
27
|
+
let lvl2 = ''
|
|
28
|
+
|
|
29
|
+
if (!hit.__docsearch_parent && hit.type !== 'lvl1' && attribute !== 'content') {
|
|
30
|
+
if (hit.type === 'content') {
|
|
31
|
+
const lvl0 =
|
|
32
|
+
getPropertyByPath(hit, `_snippetResult.hierarchy.lvl0.value`) || getPropertyByPath(hit, 'hierarchy.lvl0')
|
|
33
|
+
title = lvl0 ? `${lvl0} > ` : ''
|
|
34
|
+
|
|
35
|
+
lvl2 = getPropertyByPath(hit, `_snippetResult.hierarchy.lvl2.value`) || getPropertyByPath(hit, 'hierarchy.lvl2')
|
|
36
|
+
lvl2 = lvl2 ? ` > ${lvl2}` : ''
|
|
37
|
+
} else {
|
|
38
|
+
const lvl1 =
|
|
39
|
+
getPropertyByPath(hit, `_snippetResult.hierarchy.lvl1.value`) || getPropertyByPath(hit, 'hierarchy.lvl1')
|
|
40
|
+
title = lvl1 ? `${lvl1} > ` : ''
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
26
44
|
return createElement(tagName, {
|
|
27
45
|
...rest,
|
|
28
46
|
dangerouslySetInnerHTML: {
|
|
29
|
-
__html: getPropertyByPath(hit, `_snippetResult.${attribute}.value`) || getPropertyByPath(hit, attribute)
|
|
47
|
+
__html: `${title}${getPropertyByPath(hit, `_snippetResult.${attribute}.value`) || getPropertyByPath(hit, attribute)}${lvl2}`,
|
|
30
48
|
},
|
|
31
49
|
})
|
|
32
50
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type InternalDocSearchHit = DocSearchHit & {
|
|
2
|
-
__docsearch_parent
|
|
2
|
+
__docsearch_parent?: InternalDocSearchHit | null
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
export type StoredDocSearchHit = Omit<
|
|
5
|
+
export type StoredDocSearchHit = Omit<InternalDocSearchHit, '_highlightResult' | '_snippetResult'>
|
|
6
6
|
|
|
7
7
|
type ContentType = 'content' | 'lvl0' | 'lvl1' | 'lvl2' | 'lvl3' | 'lvl4' | 'lvl5' | 'lvl6'
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brillout/docpress",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@brillout/picocolors": "^1.0.10",
|
|
7
|
-
"@docsearch/css": "
|
|
7
|
+
"@docsearch/css": "3.6.1",
|
|
8
8
|
"@docsearch/react": "3.6.1",
|
|
9
9
|
"@mdx-js/mdx": "3.0.1",
|
|
10
10
|
"@mdx-js/react": "3.0.1",
|