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的动漫类博客主题,简洁,漂亮,多色彩,多种自定义功能,提供文章海报分享,说说,相册,评论等特色功�?
25 lines (24 loc) • 1.02 kB
JavaScript
import { isLinkHttp, removeLeadingSlash, removeEndingSlash, } from '@vuepress/shared';
import { resolveRepoType } from './resolveRepoType';
export const editLinkPatterns = {
GitHub: ':repo/edit/:branch/:path',
GitLab: ':repo/-/edit/:branch/:path',
Gitee: ':repo/edit/:branch/:path',
Bitbucket: ':repo/src/:branch/:path?mode=edit&spa=0&at=:branch&fileviewer=file-view-default',
};
export const resolveEditLink = ({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }) => {
const repoType = resolveRepoType(docsRepo);
let pattern;
if (editLinkPattern) {
pattern = editLinkPattern;
}
else if (repoType !== null) {
pattern = editLinkPatterns[repoType];
}
if (!pattern)
return null;
return pattern
.replace(/:repo/, isLinkHttp(docsRepo) ? docsRepo : `https://github.com/${docsRepo}`)
.replace(/:branch/, docsBranch)
.replace(/:path/, removeLeadingSlash(`${removeEndingSlash(docsDir)}/${filePathRelative}`));
};