[英]Discover Meteor Microscope Share It Button
如何在“讨论”按钮的左侧添加“共享”按钮。 我希望按钮与当前的“讨论”按钮具有相同的样式/颜色。
我从https://atmospherejs.com/joshowens/shareit添加了软件包
我将{{> shareit}}添加到了post_item.html中。
<template name="postItem">
<div class="post">
<a href="#" class="upvote btn btn-default {{upvotedClass}}">$</a>
<div class="post-content">
<h3>{{title}}</h3>
<p>
{{pluralize votes "Vote"}},
by {{author}},
<a href="{{pathFor 'postPage'}}">{{pluralize commentsCount "comment"}}</a>
{{#if ownPost}}<a href="{{pathFor 'postEdit'}}">Edit</a>{{/if}}
</p>
</div>
<a href="{{pathFor 'postPage'}}" class="discuss btn btn-default">Reply</a>
</div>
</template>
这是假定对其进行配置。 是否将其放置在post.item.html中? 如果是这样,怎么办? 我只想要Twitter按钮。
ShareIt.configure({
useFB: true, // boolean (default: true)
// Whether to show the Facebook button
useTwitter: true, // boolean (default: true)
// Whether to show the Twitter button
useGoogle: true, // boolean (default: true)
// Whether to show the Google+ button
classes: "large btn", // string (default: 'large btn')
// The classes that will be placed on the sharing buttons, bootstrap by default.
iconOnly: false, // boolean (default: false)
// Don't put text on the sharing buttons
applyColors: true // boolean (default: true)
// apply classes to inherit each social networks background color
});
是否可以在post_item.js中启用任何图像卡? 我不知道如何将其正确地放入。
Template.article.helpers({
shareData: function() {
return {
title: this.data,
author: Meteor.users.findOne(this.authorId)
}
});
这是post_item.js文件。
Template.postItem.helpers({
ownPost: function() {
return this.userId == Meteor.userId();
},
upvotedClass: function() {
var userId = Meteor.userId();
if (userId && !_.include(this.upvoters, userId)) {
return 'btn-primary upvotable';
} else {
return 'disabled';
}
}
});
Template.postItem.events({
'click .upvotable': function(e) {
e.preventDefault();
Meteor.call('upvote', this._id);
}
});
因此,您有一个模板:
<template name="postItem">
...
{{>shareIt shareData}}
</template>
这意味着您还有一个模板对象可以在某处进行匹配:
Template.postItem
这可能包裹在以下内容中:
if (Meteor.isClient) {
Template.postItem.helpers({
// your helper can hang out here:
shareData: function() {
return {
title: this.data,
author: Meteor.users.findOne(this.authorId)
};
};
});
// You can also put your ShareIt.configure here:
ShareIt.configure({
useFB: false,
useTwitter: true,
useGoogle: false,
classes: "large btn",
iconOnly: true,
applyColors: true
});
};
上面还将仅显示Twitter图标。
现在要放入哪个文件取决于您的应用程序结构。 如果您有一个post_item.js并将其发送到客户端(例如,它位于项目的客户端文件夹中,或者不在项目的其他特殊用途文件夹中,如下所述: http:/ /docs.meteor.com/#/full/structuringyourapp ),那么以上内容对您来说就很有效。 如果您遇到错误,请随时将其添加到问题中,以便我们提供帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.