Skip to content

Commit cdbb52a

Browse files
committed
Support Emoji interpolation in text tag
1 parent 3e3665c commit cdbb52a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

docs/concepts/text.md

+12
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ The above code will create a text like this:
138138

139139
> Hello, [@fedify@hollo.social](https://hollo.social/@fedify).
140140
141+
### `Emoji`
142+
143+
*This API is available since BotKit 0.2.0.*
144+
145+
If you put an `Emoji` object (provided by Fedify) inside the interpolation,
146+
it will be rendered as a custom emoji. You usually get `Emoji` objects from
147+
the `Reaction.emoji` property. For example:
148+
149+
~~~~ typescript
150+
text`Here's a custom emoji: ${reaction.emoji}.`
151+
~~~~
152+
141153
### `URL` object
142154

143155
If you put a `URL` object inside the interpolation, it will be rendered as a

src/text.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
import {
1717
type Actor,
18-
type Emoji,
18+
Emoji,
1919
getActorHandle,
2020
isActor,
2121
Link,
@@ -129,6 +129,7 @@ export class TemplatedText<TContextData>
129129
if (isText<TContextData>(v)) return v;
130130
if (v instanceof URL) return link(v);
131131
if (isActor(v)) return mention(v);
132+
if (v instanceof Emoji) return customEmoji(v);
132133
return new PlainText(String(v));
133134
});
134135
}

0 commit comments

Comments
 (0)