a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto bluesky typescript npm
101
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(bluesky-richtext-builder)!: accept display text in addTag

closes https://github.com/mary-ext/atcute/issues/63

Mary 584603ac ef715567

+14 -7
+5
.changeset/brown-ants-stare.md
··· 1 + --- 2 + '@atcute/bluesky-richtext-builder': major 3 + --- 4 + 5 + accept display text in addTag
+6 -5
packages/bluesky/richtext-builder/README.md
··· 73 73 .addText('hello ') 74 74 .addMention('@bsky.app', 'did:plc:z72i7hdynmk6r22z27h6tvur') 75 75 .addText('! ') 76 - .addTag('atproto'); 76 + .addTag('#atproto', 'atproto'); 77 77 78 78 await ok( 79 79 rpc.post('com.atproto.repo.createRecord', { ··· 140 140 141 141 ### adding hashtags 142 142 143 - hashtags are added without the `#` prefix - it's added automatically: 144 - 145 143 ```ts 146 - const rt = new RichtextBuilder().addText('loving ').addTag('atproto').addText(' development!'); 144 + const rt = new RichtextBuilder() 145 + .addText('loving ') 146 + .addTag('#atproto', 'atproto') 147 + .addText(' development!'); 147 148 148 149 // text: "loving #atproto development!" 149 150 ``` ··· 168 169 there are multiple ways to get the composed rich text: 169 170 170 171 ```ts 171 - const rt = new RichtextBuilder().addText('hello ').addTag('world'); 172 + const rt = new RichtextBuilder().addText('hello ').addTag('#world', 'world'); 172 173 173 174 // via getters 174 175 const text = rt.text;
+3 -2
packages/bluesky/richtext-builder/lib/index.ts
··· 129 129 130 130 /** 131 131 * Add inline hashtag to the rich text 132 + * @param text Text to display 132 133 * @param tag The tag, without the pound prefix 133 134 * @returns The builder instance, for chaining 134 135 */ 135 - addTag(tag: string): this { 136 - return this.addDecoratedText('#' + tag, { $type: 'app.bsky.richtext.facet#tag', tag: tag }); 136 + addTag(text: string, tag: string): this { 137 + return this.addDecoratedText(text, { $type: 'app.bsky.richtext.facet#tag', tag: tag }); 137 138 } 138 139 } 139 140