feat(theme): add fullname prop support for RepoCard, close #669 (#670)

* feat(theme): add `fullname` prop support for `RepoCard`, close #669

* feat: add archive repo status
This commit is contained in:
pengzhanbo 2025-08-19 23:14:31 +08:00 committed by GitHub
parent e8e8614d6e
commit 49d84dcfb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 4 deletions

View File

@ -54,6 +54,15 @@ export default defineClientConfig({
仓库地址,格式为 `owner/repo`
:::
::: field name="fullname" type="boolean" optional
是否显示完整的仓库名称。
完整的仓库名称为 `owner/repo`
- 如果 owner 为个人,则默认不显示完整的仓库名称,仅显示 `repo`
- 如果 owner 为组织,则默认显示完整的仓库名称。
:::
::::
## 示例

View File

@ -3,9 +3,10 @@ import { toRef } from 'vue'
import { ClientOnly } from 'vuepress/client'
import { useGithubRepo } from '../composables/github-repo.js'
const props = defineProps<{
const props = withDefaults(defineProps<{
repo: string
}>()
fullname?: boolean
}>(), { fullname: undefined })
const { loaded, data } = useGithubRepo(toRef(props, 'repo'))
</script>
@ -16,10 +17,10 @@ const { loaded, data } = useGithubRepo(toRef(props, 'repo'))
<span class="vpi-github-repo" />
<span class="repo-link">
<a :href="data.url" target="_blank" rel="noopener noreferrer" class="no-icon" :title="data.fullName">
{{ data.ownerType === 'Organization' ? data.fullName : data.name }}
{{ fullname || (data.ownerType === 'Organization' && typeof fullname === 'undefined') ? data.fullName : data.name }}
</a>
</span>
<span class="repo-visibility">{{ data.visibility + (data.template ? ' Template' : '') }}</span>
<span class="repo-visibility" :class="{ archived: data.archived }">{{ data.visibility + (data.template ? ' Template' : '') }}{{ data.archived ? ' archive' : '' }}</span>
</p>
<p class="repo-desc">
{{ data.description }}
@ -103,6 +104,11 @@ const { loaded, data } = useGithubRepo(toRef(props, 'repo'))
transition: color var(--vp-t-color), border var(--vp-t-color);
}
.vp-repo-card .repo-visibility.archived {
color: var(--vp-c-warning-1);
border-color: var(--vp-c-warning-2);
}
.vp-repo-card .repo-desc {
flex: 1 2;
font-size: 14px;

View File

@ -19,6 +19,7 @@ export interface GithubRepoInfo {
watchers: number
language: string
languageColor: string
archived: boolean
visibility: 'Private' | 'Public' // private, public
template: boolean
ownerType: 'User' | 'Organization'