mirror of
https://github.com/fmhy/edit.git
synced 2026-01-26 09:51:02 +00:00
* tooltips * feat: Add numerous new notes, refactor the tooltip component, and update dependencies. * notes * fix: tooltip
23 lines
569 B
TypeScript
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
|
|
}
|
|
}
|