Reddit風テーマを使用しています。ホームやカテゴリなどのトピック一覧表示時、投稿の「いいね」数を表示する方法はありますか?この解決策を試しましたが、動作しませんでした。
その投稿はかなり昔のものですね
Add Likes Column のテーマコンポーネントが、あなたが探しているものかもしれません
Redditish (https://www.carptalk-online.co.uk/) を使っているので、それが自分に必要かどうかはわかりません
おそらく無理でしょう。そのテーマはデフォルトのトピック一覧を上書きしているためです。デフォルトとは異なる設定を使用している場合、デフォルト向けに共有されている解決策が適用できない可能性が高いです。これが、ヘルプを依頼する際にその旨を伝えることが重要とされる理由です。
この機能をサポートしているテーマのフォーク版を使用するか、あるいは作者にこの機能の追加(設定で切り替え可能なオプションとしてなど)を依頼する必要があるでしょう。
Moinさん、ありがとうございます。テーマをフォークし、javascripts/discourse/connectors/topic-list-item/item.gjs を編集しました。
誰かの役に立てば幸いです。
- これを追加しました
get likeCount() {
return (
this.args.outletArgs.topic.like_count ??
this.args.outletArgs.topic.likeCount ??
0
);
}
この下です。
@action
share(event) {
event.stopPropagation();
this.modal.show(ShareTopicModal, {
model: { topic: this.args.outletArgs.topic },
});
}
get likeCount() {
return (
this.args.outletArgs.topic.like_count ??
this.args.outletArgs.topic.likeCount ??
0
);
}
<template>
- 次に、これを
<div class="custom-topic-layout_bottom-bar">
<span class="reply-count">
{{icon "reply"}}
{{@outletArgs.topic.replyCount}}
{{i18n "replies"}}
</span>
これに変更しました:
<div class="custom-topic-layout_bottom-bar">
<span class="like-count">
{{icon "heart"}}
{{this.likeCount}}
Likes
</span>
<span class="reply-count">
{{icon "reply"}}
{{@outletArgs.topic.replyCount}}
{{i18n "replies"}}
</span>
スクリーンショットを共有して、どのような見た目か示してもらえますか?
