Files
fmhy/docs/.vitepress/utils/tooltips.ts
bread 8936cc3545 tooltips (#4611)
* tooltips

* feat: Add numerous new notes, refactor the tooltip component, and update dependencies.

* notes

* fix: tooltip
2026-01-21 17:27:26 -08:00

23 lines
569 B
TypeScript

import { existsSync, readFileSync } from 'node:fs'
import { join, resolve } from 'pathe'
export interface TooltipData {
id: string
content: string
}
const notesDir = resolve(process.cwd(), 'docs/.vitepress/notes')
export function getTooltip(id: string): TooltipData | undefined {
const filePath = join(notesDir, `${id}.md`)
if (!existsSync(filePath)) return undefined
try {
const content = readFileSync(filePath, 'utf-8').trim()
return { id, content }
} catch (e) {
console.warn(`Error reading tooltip ${id}:`, e)
return undefined
}
}