mirror of
https://github.com/simstudioai/sim.git
synced 2026-11-28 09:57:25 +08:00
* fix(docs): keep search responsive and contain sidebar scrolling * fix(docs): strengthen search cancellation and IPv6 checks
17 lines
678 B
TypeScript
17 lines
678 B
TypeScript
import { createHash } from 'node:crypto'
|
|
import { compareStrings } from '@sim/utils/string'
|
|
import type { DocsPage } from '@/lib/content/types'
|
|
|
|
export function normalizeSearchText(value: string): string {
|
|
return value.toLowerCase().normalize('NFKD').replace(/\p{M}/gu, '')
|
|
}
|
|
|
|
/** Couples generated search data to exactly the catalog content it cites. */
|
|
export function searchCatalogHash(pages: Pick<DocsPage, 'id' | 'url' | 'contentHash'>[]): string {
|
|
const identities = pages
|
|
.filter((page) => page.url !== '/')
|
|
.map((page) => `${page.id}:${page.contentHash}`)
|
|
.sort(compareStrings)
|
|
return createHash('sha256').update(identities.join('\n')).digest('hex')
|
|
}
|