discourse-ai/assets/javascripts/discourse/components/ai-topic-gist.gjs

31 lines
784 B
Plaintext
Raw Normal View History

import Component from "@glimmer/component";
import { service } from "@ember/service";
2024-11-19 15:33:34 -05:00
import { htmlSafe } from "@ember/template";
import { emojiUnescape, sanitize } from "discourse/lib/text";
export default class AiTopicGist extends Component {
2024-11-19 15:33:34 -05:00
@service gists;
2024-11-19 15:33:34 -05:00
get shouldShow() {
return this.gists.preference === "table-ai" && this.gists.shouldShow;
}
2024-11-19 15:33:34 -05:00
get gistOrExcerpt() {
const topic = this.args.topic;
const gist = topic.get("ai_topic_gist");
const excerpt = emojiUnescape(sanitize(topic.get("excerpt")));
return gist || excerpt;
}
<template>
2024-11-19 15:33:34 -05:00
{{#if this.shouldShow}}
{{#if this.gistOrExcerpt}}
<div class="excerpt">
<div>{{htmlSafe this.gistOrExcerpt}}</div>
</div>
2024-11-19 15:33:34 -05:00
{{/if}}
{{/if}}
</template>
}