import { resolveRoute } from 'vuepress/client' /** * Resolve the text and the icon of a link from the metadata of its page * * 从页面元数据解析链接的文本与图标 * * @param link - The link to resolve / 要解析的链接 * @param currentPath - The current route path / 当前路由路径 * @returns Resolved text and icon, empty when the page is not found / * 解析后的文本与图标,页面不存在时为空 */ export const resolveLinkMeta = ( link: string, currentPath?: string, ): { icon?: string; text?: string } => { const { meta, notFound } = resolveRoute<{ icon?: string title?: string }>(link, currentPath) if (notFound) return {} return { ...(meta.title ? { text: meta.title } : {}), ...(meta.icon ? { icon: meta.icon } : {}), } }