The comments module

Similar to the image's helper module, the comments module will return a collection of the newest comments posted to the site. An idea of particular interest is that each comment also has an image attached to it, so that the actual image for each comment can be displayed as a thumbnail when displaying the list of comments (otherwise, we lose context when we see a random list of comments with no related image).

Create the helpers/comments.js file, and insert the following code:

module.exports = {
newest() {
let comments = [{
image_id: 1,
email: '[email protected]',
name: 'Test Tester',
gravatar: 'http://lorempixel.com/75/75/animals/1',
comment: 'This is a test comment...',
timestamp: Date.now(),
image: {
uniqueId: 1,
title: 'Sample Image 1',
description: '',
filename: 'sample1.jpg',
Views: 0,
likes: 0,
timestamp: Date.now
}
}, {
image_id: 1,
email: '[email protected]',
name: Test Tester ',
gravatar: 'http://lorempixel.com/75/75/animals/2',
comment: 'Another followup comment!',
timestamp: Date.now(),
image: {
uniqueId: 1,
title: 'Sample Image 1',
description: '',
filename: 'sample1.jpg',
Views: 0,
likes: 0,
timestamp: Date.now
}
}];
return comments;
}
};

Again, this is just a basic JavaScript array of objects with a few properties for each comment, one of which is an actual image and its properties (the image property should look familiar, since it's the same as one of the items in the image's helper module).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.34.226