mirror of
https://github.com/elk-zone/elk
synced 2024-11-27 22:38:11 +09:00
feat: author on GitHub issues and PR cards
This commit is contained in:
parent
60a8673757
commit
2e97780899
@ -14,12 +14,9 @@ interface Meta {
|
||||
details: string
|
||||
repo?: string
|
||||
number?: string
|
||||
extra?: {
|
||||
state: string
|
||||
author?: {
|
||||
avatar: string
|
||||
user: string
|
||||
}
|
||||
author?: {
|
||||
avatar: string
|
||||
user: string
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,8 +40,10 @@ const meta = $computed(() => {
|
||||
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 author = props.card.authorName
|
||||
const info = $ref<Meta>({
|
||||
type,
|
||||
user,
|
||||
@ -53,23 +52,13 @@ const meta = $computed(() => {
|
||||
repo,
|
||||
number,
|
||||
avatar,
|
||||
author: author
|
||||
? {
|
||||
avatar: `https://github.com/${author}.png?size=64`,
|
||||
user: author,
|
||||
}
|
||||
: undefined,
|
||||
})
|
||||
/* 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
|
||||
could ask GitHub to add it.
|
||||
|
||||
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,
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
*/
|
||||
return info
|
||||
})
|
||||
</script>
|
||||
@ -112,14 +101,14 @@ const meta = $computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
<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>
|
||||
<span text-xl text-primary font-bold>@{{ meta.extra?.author?.user }}</span>
|
||||
<span text-lg text-primary>@{{ meta.author?.user }}</span>
|
||||
</div>
|
||||
<div v-else />
|
||||
<div text-2xl i-ri:github-fill text-secondary />
|
||||
<div text-3xl i-ri:github-fill text-secondary />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user