-
+
{{ fullname || (data.ownerType === 'Organization' && typeof fullname === 'undefined') ? data.fullName : data.name }}
@@ -67,10 +68,10 @@ const { loaded, data } = useGithubRepo(toRef(props, 'repo'))
.vp-repo-card .repo-name {
display: flex;
- gap: 0 8px;
+ gap: 0 6px;
align-items: center;
max-width: 100%;
- font-size: 16px;
+ font-size: 14px;
}
.vp-repo-card .repo-link {
@@ -96,7 +97,7 @@ const { loaded, data } = useGithubRepo(toRef(props, 'repo'))
.vp-repo-card .repo-visibility {
display: inline-block;
padding: 0 8px;
- font-size: 14px;
+ font-size: 12px;
line-height: 20px;
color: var(--vp-c-text-2);
border: solid 1px var(--vp-c-divider);
@@ -111,8 +112,8 @@ const { loaded, data } = useGithubRepo(toRef(props, 'repo'))
.vp-repo-card .repo-desc {
flex: 1 2;
- font-size: 14px;
- line-height: 22px;
+ font-size: 12px;
+ line-height: 18px;
color: var(--vp-c-text-2);
transition: color var(--vp-t-color);
}
@@ -123,7 +124,7 @@ const { loaded, data } = useGithubRepo(toRef(props, 'repo'))
gap: 8px 14px;
align-items: center;
justify-content: flex-start;
- font-size: 14px;
+ font-size: 12px;
}
.vp-repo-card .repo-info p {
@@ -148,6 +149,14 @@ const { loaded, data } = useGithubRepo(toRef(props, 'repo'))
border-radius: 100%;
}
+.vpi-gitee-repo {
+ --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23c71d23' d='M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12a12 12 0 0 0 12-12A12 12 0 0 0 12 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.59.59 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296Z'/%3E%3C/svg%3E");
+
+ color: #c71d23;
+ transition: color var(--vp-t-color);
+ transform: translateY(2px);
+}
+
.vpi-github-repo {
--icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7a.75.75 0 1 1-1.072 1.05A2.5 2.5 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.5 2.5 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.25.25 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z'/%3E%3C/svg%3E");
diff --git a/theme/src/client/features/composables/github-repo.ts b/theme/src/client/features/composables/repo.ts
similarity index 72%
rename from theme/src/client/features/composables/github-repo.ts
rename to theme/src/client/features/composables/repo.ts
index efcff75c..cc1caa38 100644
--- a/theme/src/client/features/composables/github-repo.ts
+++ b/theme/src/client/features/composables/repo.ts
@@ -2,12 +2,12 @@ import type { MaybeRef, Ref } from 'vue'
import { useLocalStorage } from '@vueuse/core'
import { computed, ref, toValue, watch } from 'vue'
-interface GithubRepoLicense {
+interface RepoLicense {
name: string
url: string
}
-export interface GithubRepoInfo {
+export interface RepoInfo {
name: string
fullName: string
description: string
@@ -23,7 +23,7 @@ export interface GithubRepoInfo {
visibility: 'Private' | 'Public' // private, public
template: boolean
ownerType: 'User' | 'Organization'
- license: GithubRepoLicense | null
+ license: RepoLicense | null
}
/**
@@ -31,31 +31,36 @@ export interface GithubRepoInfo {
* 默认缓存 6 小时 时间
*/
const storage = useLocalStorage('__VUEPRESS_GITHUB_REPO__', {} as Record)
interface UseGithubRepoResult {
- data: Ref
+ data: Ref
loaded: Ref
}
-export function useGithubRepo(repo: MaybeRef): UseGithubRepoResult {
+export function useGithubRepo(
+ repo: MaybeRef,
+ provider: MaybeRef<'github' | 'gitee' | undefined>,
+): UseGithubRepoResult {
const repoRef = computed(() => {
const info = toValue(repo)
const [owner = '', name = ''] = info.split('/')
return { owner, name }
})
- const data = ref(null)
+ const providerRef = computed(() => toValue(provider) ?? 'github')
+
+ const data = ref(null)
const loaded = ref(false)
async function fetchData() {
- const { owner, name } = repoRef.value
+ const { owner, name } = toValue(repoRef)
if (__VUEPRESS_SSR__ || !owner || !name)
return
- const key = `${owner}/${name}`
- const cached = storage.value[`${owner}/${name}`]
+ const key = `${providerRef.value === 'github' ? '' : `${providerRef.value}:`}${owner}/${name}`
+ const cached = storage.value[key]
if (cached?.info?.name && Date.now() - cached.updatedAt <= 86400000) {
data.value = cached.info
loaded.value = true
@@ -64,8 +69,8 @@ export function useGithubRepo(repo: MaybeRef): UseGithubRepoResult {
loaded.value = false
try {
- const res = await fetch(`https://api.pengzhanbo.cn/github/repo/${owner}/${name}`)
- .then(res => res.json()) as GithubRepoInfo
+ const res = await fetch(`https://api.pengzhanbo.cn/${providerRef.value}/repo/${owner}/${name}`)
+ .then(res => res.json()) as RepoInfo
loaded.value = true