Skip to content

Commit

Permalink
feat: show avatar on package list and detail
Browse files Browse the repository at this point in the history
  • Loading branch information
favoyang committed Dec 30, 2019
1 parent 76859ed commit e02f965
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 9 deletions.
9 changes: 9 additions & 0 deletions app/utils/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,17 @@ const preparePackage = function(doc) {
// owner
doc.owner = ghUrl.owner;
doc.ownerUrl = `https://${ghUrl.hostname}/${ghUrl.owner}`;
doc.ownerAvatarUrl = doc.ownerUrl.toLowerCase().includes("github")
? `https://${ghUrl.hostname}/${ghUrl.owner}.png`
: null;
// hunter
if (doc.hunter) {
doc.hunterUrl = `https://${ghUrl.hostname}/${doc.hunter}`;
doc.hunterAvatarUrl = `https://${ghUrl.hostname}/${doc.hunter}.png`;
} else {
doc.hunter = "-";
doc.hunterUrl = null;
doc.hunterAvatarUrl = null;
}
// license
if (doc.licenseSpdxId && spdx[doc.licenseSpdxId])
Expand All @@ -97,6 +102,10 @@ const preparePackage = function(doc) {
doc.parentOwnerUrl = parentGHUrl
? `https://${parentGHUrl.hostname}/${parentGHUrl.owner}`
: null;
doc.parentOwnerAvatarUrl =
doc.parentOwnerUrl && doc.parentOwnerUrl.toLowerCase().includes("github")
? `https://${parentGHUrl.hostname}/${parentGHUrl.owner}.png`
: null;
return doc;
};

Expand Down
60 changes: 53 additions & 7 deletions docs/.vuepress/theme/layouts/PackageDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,58 @@
</section>
<section class="col-6 col-sm-12">
<h2>Author</h2>
<NavLink
<a
v-if="parentOwnerNavLink"
:item="parentOwnerNavLink"
/>
<span v-if="parentOwnerNavLink">,</span>
<NavLink :item="ownerNavLink" />
:href="parentOwnerNavLink.link"
target="_blank"
rel="noopener noreferrer"
class="nav-link external"
>
<span class="chip">
<img
v-if="$package.parentOwnerAvatarUrl"
:src="$package.parentOwnerAvatarUrl"
:alt="$package.parentOwner"
class="avatar avatar-sm"
/>
<i v-else class="fa fa-user"></i>
{{ parentOwnerNavLink.text }}
</span>
</a>
<a
:href="ownerNavLink.link"
target="_blank"
rel="noopener noreferrer"
class="nav-link external"
>
<span class="chip">
<img
:src="$package.ownerAvatarUrl"
:alt="$package.owner"
class="avatar avatar-sm"
/>
{{ ownerNavLink.text }}
</span>
</a>
</section>
<section class="col-6 col-sm-12">
<h2>Discovered by</h2>
<NavLink v-if="$package.hunterUrl" :item="hunterNavLink" />
<a
v-if="$package.hunterUrl"
:href="hunterNavLink.link"
target="_blank"
rel="noopener noreferrer"
class="nav-link external"
>
<span class="chip">
<img
:src="$package.hunterAvatarUrl"
:alt="hunterNavLink.text"
class="avatar avatar-sm"
/>
{{ hunterNavLink.text }}
</span>
</a>
<span v-else>{{ this.$package.hunter }}</span>
</section>
<section class="col-6 col-sm-12">
Expand Down Expand Up @@ -577,7 +619,11 @@ See more in the [${this.$package.repo}](${this.$package.repoUrl}) repository.
top .1rem

i, img
vertical-align: middle
vertical-align middle

i.fa-user
padding-right 0.2rem
color $textColor

.fork
font-size 0.6rem
Expand Down
14 changes: 12 additions & 2 deletions docs/.vuepress/theme/layouts/PackageList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,21 @@
</p>
<div>
<span class="chip">
<i class="fa fa-user"></i>
<img
:src="pkg.ownerAvatarUrl"
:alt="pkg.owner"
class="avatar avatar-sm"
/>
{{ pkg.owner }}
</span>
<span v-if="pkg.parentOwner" class="chip">
<i class="fa fa-user"></i>
<img
v-if="pkg.parentOwnerAvatarUrl"
:src="pkg.parentOwnerAvatarUrl"
:alt="pkg.parentOwner"
class="avatar avatar-sm"
/>
<i v-else class="fa fa-user"></i>
{{ pkg.parentOwner }}
</span>
<span class="chip">
Expand Down

0 comments on commit e02f965

Please sign in to comment.