forked from Mirrors/elk
feat: author on GitHub issues and PR cards
This commit is contained in:
parent
60a8673757
commit
2e97780899
1 changed files with 16 additions and 27 deletions
|
@ -14,13 +14,10 @@ interface Meta {
|
||||||
details: string
|
details: string
|
||||||
repo?: string
|
repo?: string
|
||||||
number?: string
|
number?: string
|
||||||
extra?: {
|
|
||||||
state: string
|
|
||||||
author?: {
|
author?: {
|
||||||
avatar: string
|
avatar: string
|
||||||
user: string
|
user: string
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const meta = $computed(() => {
|
const meta = $computed(() => {
|
||||||
|
@ -43,8 +40,10 @@ const meta = $computed(() => {
|
||||||
type = 'pull'
|
type = 'pull'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const avatar = `https://github.com/${user}.png`
|
const avatar = `https://github.com/${user}.png?size=256`
|
||||||
const details = (props.card.title ?? '').replace('GitHub - ', '').replace(`${repoPath}: `, '').split(' · ')[0]
|
const details = (props.card.title ?? '').replace('GitHub - ', '').replace(`${repoPath}: `, '').split(' · ')[0]
|
||||||
|
|
||||||
|
const author = props.card.authorName
|
||||||
const info = $ref<Meta>({
|
const info = $ref<Meta>({
|
||||||
type,
|
type,
|
||||||
user,
|
user,
|
||||||
|
@ -53,23 +52,13 @@ const meta = $computed(() => {
|
||||||
repo,
|
repo,
|
||||||
number,
|
number,
|
||||||
avatar,
|
avatar,
|
||||||
})
|
author: author
|
||||||
/* It is rate limited for anonymous usage, leaving this to play, but for now it is probably better to avoid the call
|
? {
|
||||||
We can't show the author of the PR or issue without this info, because the handle isn't in the meta. I think we
|
avatar: `https://github.com/${author}.png?size=64`,
|
||||||
could ask GitHub to add it.
|
user: author,
|
||||||
|
|
||||||
if (number) {
|
|
||||||
fetch(`https://api.github.com/repos/${user}/${repo}/issues/${number}`).then(res => res.json()).then((data) => {
|
|
||||||
info.extra = {
|
|
||||||
state: data.state as string,
|
|
||||||
author: {
|
|
||||||
avatar: data.user.avatar_url as string,
|
|
||||||
user: data.user.login as string,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
: undefined,
|
||||||
})
|
})
|
||||||
}
|
|
||||||
*/
|
|
||||||
return info
|
return info
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -112,14 +101,14 @@ const meta = $computed(() => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div flex justify-between>
|
<div flex justify-between>
|
||||||
<div v-if="meta.extra" flex gap-2 items-center>
|
<div v-if="meta.author" flex class="gap-2.5" items-center>
|
||||||
<div>
|
<div>
|
||||||
<img w-6 aspect-square width="20" height="20" rounded-full :src="meta.extra?.author?.avatar">
|
<img w-8 aspect-square width="25" height="25" rounded-full :src="meta.author?.avatar">
|
||||||
</div>
|
</div>
|
||||||
<span text-xl text-primary font-bold>@{{ meta.extra?.author?.user }}</span>
|
<span text-lg text-primary>@{{ meta.author?.user }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-else />
|
<div v-else />
|
||||||
<div text-2xl i-ri:github-fill text-secondary />
|
<div text-3xl i-ri:github-fill text-secondary />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue