-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathget-author.js
More file actions
17 lines (13 loc) · 702 Bytes
/
Copy pathget-author.js
File metadata and controls
17 lines (13 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module.exports = function(post, data) {
if (!post) return 'Missing post object parameter'
var author_handle, author;
if (post._categories && post._categories.length)
author_handle = post._categories[1] ? post._categories[1] : 'admin'
else
// sometimes post._categories isnt present, we should fallback by extracting it from the url
author_handle = post._url && post._url.split('/')[2]
author = data.authors[author_handle]
author.image = author.twitter ? 'https://twitter.com/'+ author.twitter +'/profile_image?size=original' : 'http://placehold.it/200x200?text=' + author.displayname
author.hero = '/library/' + author_handle + '/' + author['heroimage']
return author
}