UBERF-4348: Mentions. Fix render props types and component props types (#4022)

Signed-off-by: Maxim Karmatskikh <mkarmatskih@gmail.com>
This commit is contained in:
Maksim Karmatskikh
2023-11-21 10:32:49 +07:00
committed by GitHub
parent 273f3de0a3
commit d36dcdc7da
2 changed files with 18 additions and 13 deletions
+4 -4
View File
@@ -34,15 +34,15 @@ function createIndexedReader (
}
}
function readAndMapProps (reader: IndexedReader, props: ClassSearchConfigProps[]): Record<string, string> {
const res: Record<string, string> = {}
function readAndMapProps (reader: IndexedReader, props: ClassSearchConfigProps[]): Record<string, any> {
const res: Record<string, any> = {}
for (const prop of props) {
if (typeof prop === 'string') {
res[prop] = reader.get(prop)
} else {
for (const [propName, rest] of Object.entries(prop)) {
if (rest.length > 1) {
const val = reader.getDoc(rest[0])?.get(rest[1]) ?? ''
const val = reader.getDoc(rest[0])?.get(rest[1])
res[propName] = Array.isArray(val) ? val[0] : val
}
}
@@ -135,6 +135,6 @@ export function mapSearchResultDoc (hierarchy: Hierarchy, raw: IndexedDoc): Sear
return doc
}
function fillTemplate (tmpl: string, props: Record<string, string>): string {
function fillTemplate (tmpl: string, props: Record<string, any>): string {
return tmpl.replace(/{(.*?)}/g, (_, key: string) => props[key])
}