mirror of
https://github.com/vale981/Vulcan
synced 2025-03-12 13:36:37 -04:00
36 lines
741 B
JavaScript
36 lines
741 B
JavaScript
![]() |
/*
|
||
|
|
||
|
Comments helpers
|
||
|
|
||
|
*/
|
||
|
|
||
|
import Comments from './index.js';
|
||
|
import Posts from '../posts/index.js';
|
||
|
import Users from 'meteor/vulcan:users';
|
||
|
|
||
|
//////////////////
|
||
|
// Link Helpers //
|
||
|
//////////////////
|
||
|
|
||
|
/**
|
||
|
* @summary Get URL of a comment page.
|
||
|
* @param {Object} comment
|
||
|
*/
|
||
|
Comments.getPageUrl = function(comment, isAbsolute = false){
|
||
|
const post = Posts.findOne(comment.postId);
|
||
|
return `${Posts.getPageUrl(post, isAbsolute)}/#${comment._id}`;
|
||
|
};
|
||
|
|
||
|
///////////////////
|
||
|
// Other Helpers //
|
||
|
///////////////////
|
||
|
|
||
|
/**
|
||
|
* @summary Get a comment author's name
|
||
|
* @param {Object} comment
|
||
|
*/
|
||
|
Comments.getAuthorName = function (comment) {
|
||
|
var user = Users.findOne(comment.userId);
|
||
|
return user ? Users.getDisplayName(user) : comment.author;
|
||
|
};
|