UNPKG

hirsun-vuepress-theme-hope-plus

Version:
22 lines 960 B
import { inferRouteLink, resolveRouteWithRedirect, } from "vuepress-shared/client"; import { ArticleInfoType } from "../../shared/index.js"; /** * Resolve AutoLink props from string * */ export const resolveLinkInfo = (router, item, preferFull = false) => { const encodedPath = encodeURI(item); let result = resolveRouteWithRedirect(router, inferRouteLink(encodedPath)); // the inferred path may be wrong, so we need to resolve the original path if (result.name === "404") result = resolveRouteWithRedirect(router, encodedPath); const { fullPath, meta, name } = result; return { text: !preferFull && meta[ArticleInfoType.shortTitle] ? meta[ArticleInfoType.shortTitle] : meta[ArticleInfoType.title] || item, link: name === "404" ? item : fullPath, ...(meta[ArticleInfoType.icon] ? { icon: meta[ArticleInfoType.icon] } : {}), }; }; //# sourceMappingURL=resolveLinkInfo.js.map