This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/helpers/topic-link.js.es6

21 lines
637 B
JavaScript

import { registerUnbound } from 'discourse-common/lib/helpers';
registerUnbound('topic-link', (topic, args) => {
const title = topic.get('fancyTitle');
const url = topic.linked_post_number ?
topic.urlForPostNumber(topic.linked_post_number) :
topic.get('lastUnreadUrl');
const classes = ['title'];
if (topic.get('last_read_post_number') === topic.get('highest_post_number')) {
classes.push('visited');
}
if (args.class) {
args.class.split(" ").forEach(c => classes.push(c));
}
const result = `<a href='${url}' class='${classes.join(' ')}'>${title}</a>`;
return new Handlebars.SafeString(result);
});