Skip to content

Commit 6743055

Browse files
committed
chore: update contributor code
1 parent 190903e commit 6743055

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

client/composables/changelog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { MaybeRefOrGetter, Ref } from 'vue'
22
import type { ChangeLog } from '../../types'
33
import { computedAsync } from '@vueuse/core'
4-
import { toRef } from 'vue'
4+
import { computed } from 'vue'
55
import { useAddonGitLogConfig } from '../options'
66
import { useGitLog } from './gitlog'
77

@@ -10,7 +10,7 @@ export function useChangeLog(_path?: MaybeRefOrGetter<string>): Ref<ChangeLog[]>
1010
const gitLogOptions = useAddonGitLogConfig()
1111

1212
if (gitLogOptions.value.contributor?.mode !== 'api')
13-
return toRef([])
13+
return computed(() => gitLog.value.changeLog)
1414

1515
const contributors = computedAsync<ChangeLog[]>(
1616
async () => {

client/composables/contributor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { MaybeRefOrGetter, Ref } from 'vue'
22
import type { Contributor } from '../../types'
33
import { computedAsync } from '@vueuse/core'
4-
import { toRef, toValue } from 'vue'
4+
import { computed, toValue } from 'vue'
55
import { parseGithubUrl } from '../../utils'
66
import { useAddonGitLogConfig } from '../options'
77
import { fetchContributors } from '../services'
@@ -12,7 +12,7 @@ export function useContributor(path?: MaybeRefOrGetter<string>): Ref<Contributor
1212
const gitLogOptions = useAddonGitLogConfig()
1313

1414
if (gitLogOptions.value.contributor?.mode !== 'api')
15-
return toRef([])
15+
return computed(() => gitLog.value.contributors)
1616

1717
const contributors = computedAsync<Contributor[]>(
1818
async () => {

components/GitLogContributor.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ const contributors = computed(() => props.contributors || gitLogContributor?.val
1515
<template>
1616
<ul class="git-log-contributor" flex="~ wrap gap-2" pt-2>
1717
<li v-for="(contributor, index) in contributors" :key="index" flex="~ items-center gap-2">
18-
<span class="contributor-avatar">
19-
<a :href="contributor.github || ''" target="_blank" aria-label="Contributor image" :title="contributor.email">
20-
<img :src="contributor.avatar" width="32" height="32" :alt="contributor.name" loading="lazy" decoding="async" rounded-full>
21-
</a>
18+
<span class="contributor-avatar" :title="contributor.email">
19+
<img
20+
:src="contributor.avatar" width="32" height="32" aria-label="Contributor image"
21+
:alt="contributor.name" loading="lazy" decoding="async" rounded-full
22+
>
2223
</span>
2324

2425
<span class="contributor-name">
25-
<a :href="contributor.github || ''" target="_blank" :title="contributor.email">
26+
<a v-if="contributor?.github" :href="contributor.github" :title="contributor.github" target="_blank">
2627
{{ contributor.name }}
2728
</a>
29+
<template v-else>
30+
{{ contributor.name }}
31+
</template>
2832
</span>
2933
</li>
3034
</ul>

node/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export const addonGitLog = defineValaxyAddon<GitLogOptions>(options => ({
1515
name: pkg.name,
1616
enable: true,
1717
options: {
18-
...options,
1918
contributor: {
2019
mode: 'api',
2120
},
21+
...options,
2222
},
2323

2424
async setup(valaxy) {

types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ export interface GitLogOptions {
99
}
1010

1111
export interface Contributor extends ContributorInfo {
12+
name: string
1213
email: string
1314
avatar: string
15+
count: number
1416
github?: string | null
1517
}
1618

0 commit comments

Comments
 (0)