mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-16 18:15:17 +00:00
370a02f087
This resolves #1669. Also bumped some dependencies.
39 lines
940 B
TypeScript
39 lines
940 B
TypeScript
import Fuse, { FuseIndexRecords } from 'fuse.js'
|
|
import { getConfigSettings, getLua, getVariables } from './doc-utils'
|
|
export interface SearchItem {
|
|
kind: string
|
|
name: string
|
|
desc: string
|
|
}
|
|
export interface SearchIndex {
|
|
index: {
|
|
keys: readonly string[]
|
|
records: FuseIndexRecords
|
|
}
|
|
list: SearchItem[]
|
|
}
|
|
|
|
export function getSearchIndex() {
|
|
const cs: SearchItem[] = getConfigSettings().values.map((v) => ({
|
|
kind: 'config',
|
|
name: v.name,
|
|
desc: v.desc.substring(0, 121),
|
|
}))
|
|
const vars: SearchItem[] = getVariables().values.map((v) => ({
|
|
kind: 'var',
|
|
name: v.name,
|
|
desc: v.desc.substring(0, 121),
|
|
}))
|
|
const lua: SearchItem[] = getLua().values.map((v) => ({
|
|
kind: 'lua',
|
|
name: v.name,
|
|
desc: v.desc.substring(0, 121),
|
|
}))
|
|
const list: SearchItem[] = [...cs, ...vars, ...lua]
|
|
|
|
return {
|
|
list,
|
|
index: Fuse.createIndex<SearchItem>(['name', 'desc'], list).toJSON(),
|
|
}
|
|
}
|