aboutsummaryrefslogtreecommitdiff
path: root/lib/render.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/render.js')
-rw-r--r--lib/render.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/render.js b/lib/render.js
index fdff95c..2aef6b4 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -346,3 +346,19 @@ Render.prototype.getNameLink = function (id, cb) {
cb(null, h('a', {href: self.toUrl(id)}, name))
})
}
+
+Render.prototype.npmAuthorLink = function (author) {
+ if (!author) return
+ var url = u.ifString(author.url)
+ var email = u.ifString(author.email)
+ var name = u.ifString(author.name)
+ if (!url && !email) return name || JSON.stringify(author)
+ if (!url && email) url = 'mailto:' + email, email = null
+ if (!name && email) name = email, email = null
+ if (!name && url) name = url
+ var secondaryLink = email && h('a', {href: this.toUrl('mailto:' + email)}, email)
+ return [
+ h('a', {href: this.toUrl(url)}, name),
+ secondaryLink ? [' (', secondaryLink, ')'] : ''
+ ]
+}