From 2e97780899f55d89c962692235a374fa51ada8c9 Mon Sep 17 00:00:00 2001 From: patak Date: Tue, 20 Dec 2022 20:42:28 +0100 Subject: [PATCH] feat: author on GitHub issues and PR cards --- components/status/StatusPreviewGitHub.vue | 43 +++++++++-------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/components/status/StatusPreviewGitHub.vue b/components/status/StatusPreviewGitHub.vue index c275d7a0..5489cff4 100644 --- a/components/status/StatusPreviewGitHub.vue +++ b/components/status/StatusPreviewGitHub.vue @@ -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({ 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 }) @@ -112,14 +101,14 @@ const meta = $computed(() => {
-
+
- +
- @{{ meta.extra?.author?.user }} + @{{ meta.author?.user }}
-
+