test02/node_modules/@vuepress/theme-default/lib/client/utils/getAutoLink.js
罗佳鸿 6aa1ebe342
Some checks are pending
部署文档 / deploy-gh-pages (push) Waiting to run
first commit
2024-08-13 10:11:19 +08:00

18 lines
446 B
JavaScript

import { resolveRoute } from 'vuepress/client';
/**
* Resolve AutoLink props from string
*
* @example
* - Input: '/README.md'
* - Output: { text: 'Home', link: '/' }
*/
export const getAutoLink = (config, currentPath) => {
const { notFound, meta, path } = resolveRoute(config, currentPath);
return notFound
? { text: path, link: path }
: {
text: meta.title || path,
link: path,
};
};