diff --git a/app/assets/javascripts/discourse/widgets/post-links.js.es6 b/app/assets/javascripts/discourse/widgets/post-links.js.es6
index e1795699624..a846b6d743f 100644
--- a/app/assets/javascripts/discourse/widgets/post-links.js.es6
+++ b/app/assets/javascripts/discourse/widgets/post-links.js.es6
@@ -12,7 +12,8 @@ export default createWidget('post-links', {
},
linkHtml(link) {
- const linkBody = [new RawHtml({html: `${Discourse.Emoji.unescape(Handlebars.Utils.escapeExpression(link.title))}`})];
+ const escapedTitle = Discourse.Emoji.unescape(Handlebars.Utils.escapeExpression(link.title));
+ const linkBody = [new RawHtml({ html: `${escapedTitle}` })];
if (link.clicks) {
linkBody.push(h('span.badge.badge-notification.clicks', link.clicks.toString()));
}
@@ -20,7 +21,7 @@ export default createWidget('post-links', {
return h('li',
h('a.track-link', {
className: link.reflection ? 'inbound' : 'outbound',
- attributes: {href: link.url}
+ attributes: { href: link.url }
}, [linkBody, iconNode(link.reflection ? 'arrow-left' : 'arrow-right')])
);
},
@@ -35,28 +36,24 @@ export default createWidget('post-links', {
const result = [];
- if (dedupedLinks.length <= 5) {
- // show all links
+ // show all links
+ if (dedupedLinks.length <= 5 || !state.collapsed) {
_.each(dedupedLinks, l => result.push(this.linkHtml(l)));
} else {
// show up to 5 *incoming* links when collapsed
- if (state.collapsed) {
- const max = Math.min(5, incomingLinks.length);
- for (let i = 0; i < max; i++) {
- result.push(this.linkHtml(incomingLinks[i]));
- }
- // 'show more' link
- if (dedupedLinks.length > 5) {
- result.push(h('li', this.attach('link', {
- labelCount: `post_links.title`,
- title: "post_links.about",
- count: links.length,
- action: 'expandLinks',
- className: 'expand-links'
- })));
- }
- } else {
- _.each(dedupedLinks, l => result.push(this.linkHtml(l)));
+ const max = Math.min(5, incomingLinks.length);
+ for (let i = 0; i < max; i++) {
+ result.push(this.linkHtml(incomingLinks[i]));
+ }
+ // 'show more' link
+ if (dedupedLinks.length > max) {
+ result.push(h('li', this.attach('link', {
+ labelCount: 'post_links.title',
+ title: 'post_links.about',
+ count: links.length,
+ action: 'expandLinks',
+ className: 'expand-links'
+ })));
}
}