vuepress-theme-aurora
Version:
A vuepress-based animation blog theme, simple, beautiful, multi-color, multiple custom functions, providing article poster sharing, talk, photo album, comment and other features 一个基于vuepress的动漫类博客主题,简洁,漂亮,多色彩,多种自定义功能,提供文章海报分享,说说,相册,评论等特色功�?
29 lines (28 loc) • 813 B
JavaScript
import { useResolveRouteWithRedirect } from './useResolveRouteWithRedirect';
import myData from'@temp/my-data'
/**
* Resolve NavLink props from string
*
* @example
* - Input: '/README.md'
* - Output: { text: 'Home', link: '/' }
*/
export const useNavLink = (item) => {
const resolved = useResolveRouteWithRedirect(item);
if (resolved.name !== "404") {
for (let i = 0; i < myData.length; i++) {
if (resolved.fullPath === myData[i].path) {
resolved.meta.title = myData[i].title
return {
text: resolved.meta.title || item,
link: resolved.fullPath,
}
}
}
}else {
return {
text: resolved.meta.title || item,
link: item,
};
}
};