a web component that shows the replies to a linked bsky post as comments.
0
fork

Configure Feed

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

add text for when there's no comments

rekkice b155601f d5dbebfa

+30 -11
+1 -3
README.md
··· 45 45 46 46 then: 47 47 ```js 48 - import { register } from "bsky_comments_widget" 49 - 50 - register() 48 + import "bsky_comments_widget" 51 49 ``` 52 50 53 51 ### from Gleam (`vite-gleam` needed)
+1 -1
gleam.toml
··· 1 1 name = "bsky_comments_widget" 2 - version = "1.0.1" 2 + version = "1.0.2" 3 3 target = "javascript" 4 4 5 5 # Fill out these fields if you intend to generate HTML documentation or publish
+1 -1
package.json
··· 1 1 { 2 2 "name": "bsky_comments_widget", 3 - "version": "1.0.1", 3 + "version": "1.0.2", 4 4 "type": "module", 5 5 "main": "dist/bsky_comments_widget.umd.cjs", 6 6 "module": "dist/bsky_comments_widget.js",
+27 -6
src/bsky_comments_widget/widget.gleam
··· 90 90 "thread-container rounded-lg border-3 border-solid border-blue-200 flex flex-col gap-4 p-4 w-full mx-auto", 91 91 ), 92 92 ], 93 - list.map(thread.replies, fn(reply) { 94 - html.div([attribute.class("reply-wrapper")], [ 95 - render_post(reply), 96 - ]) 97 - }), 93 + case thread.replies { 94 + [] -> render_no_comments(thread) 95 + _ -> 96 + list.map(thread.replies, fn(reply) { 97 + html.div([attribute.class("reply-wrapper")], [ 98 + render_post(reply), 99 + ]) 100 + }) 101 + }, 98 102 ) 103 + } 104 + 105 + fn render_no_comments(thread: Post) -> List(Element(a)) { 106 + [ 107 + html.p([attribute.class("no-comments text-center")], [ 108 + html.text("No comments yet... "), 109 + html.a( 110 + [ 111 + attribute.href(post_uri_to_url(thread.uri)), 112 + attribute.class("no-comments-link block text-blue-600 hover:underline"), 113 + ], 114 + [ 115 + html.text("leave one here!"), 116 + ], 117 + ), 118 + ]), 119 + ] 99 120 } 100 121 101 122 pub fn render_post(post: Post) { ··· 199 220 "reply-section rounded-lg border-3 border-solid border-blue-200 mt-2", 200 221 ), 201 222 ], 202 - list.map(post.replies, render_post(_)) 223 + list.map(post.replies, render_post), 203 224 ) 204 225 } 205 226 [] -> element.none()