mirror of https://github.com/vuejs/vitepress
parent
b3cab2ef90
commit
3b6f17490a
@ -1,47 +0,0 @@
|
|||||||
import { computed, defineComponent, PropType } from 'vue'
|
|
||||||
import OutboundLink from './icons/OutboundLink.vue'
|
|
||||||
import { DefaultTheme } from '/@theme/config'
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
components: {
|
|
||||||
OutboundLink
|
|
||||||
},
|
|
||||||
|
|
||||||
props: {
|
|
||||||
editLinkConfig: {
|
|
||||||
type: Object as PropType<DefaultTheme.EditLinkConfig>,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
setup(props) {
|
|
||||||
const editLinkConfig = props.editLinkConfig
|
|
||||||
const repoLink = computed(() => {
|
|
||||||
if (editLinkConfig && editLinkConfig.repo) {
|
|
||||||
return /^https?:/.test(editLinkConfig.repo)
|
|
||||||
? editLinkConfig.repo
|
|
||||||
: `https://github.com/${editLinkConfig.repo}`
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
})
|
|
||||||
const repoLabel = computed(() => {
|
|
||||||
if (!repoLink.value) return
|
|
||||||
const repoHosts = repoLink.value.match(/^https?:\/\/[^/]+/)
|
|
||||||
if (!repoHosts) return
|
|
||||||
const repoHost = repoHosts[0]
|
|
||||||
const platforms = ['GitHub', 'GitLab', 'Bitbucket']
|
|
||||||
for (let i = 0; i < platforms.length; i++) {
|
|
||||||
const platform = platforms[i]
|
|
||||||
if (new RegExp(platform, 'i').test(repoHost)) {
|
|
||||||
return platform
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'Source'
|
|
||||||
})
|
|
||||||
return {
|
|
||||||
repoLink,
|
|
||||||
repoLabel
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
@ -1,22 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a
|
|
||||||
v-if="repoLink"
|
|
||||||
:href="repoLink"
|
|
||||||
class="repo-link"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
{{ repoLabel }}
|
|
||||||
<OutboundLink />
|
|
||||||
</a>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script src="./NavRepoLink"></script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.repo-link {
|
|
||||||
margin-left: 1.5rem;
|
|
||||||
color: var(--text-color);
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
</style>
|
|
Loading…
Reference in new issue