tangled
alpha
login
or
join now
claycow.com
/
claycow
0
fork
atom
A Astro blog hosted on Vercel
0
fork
atom
overview
issues
pulls
pipelines
update bluesky comments component with new url
Clayton Cook
6 months ago
ac5b91ce
f340a683
1/1
deploy.yaml
success
38s
+118
-134
2 changed files
expand all
collapse all
unified
split
src
components
organisms
BlueskyComments.svelte
utils
getBlogPostComments.ts
+115
-131
src/components/organisms/BlueskyComments.svelte
reviewed
···
1
1
<script lang="ts">
2
2
-
import { formatDate } from "@/utils";
3
3
-
import getBlogPostComments from "@/utils/getBlogPostComments";
2
2
+
import { formatDate } from "@/utils";
3
3
+
import getBlogPostComments from "@/utils/getBlogPostComments";
4
4
5
5
-
interface Props {
6
6
-
blogTitle: string;
7
7
-
}
5
5
+
interface Props {
6
6
+
blogTitle: string;
7
7
+
}
8
8
9
9
-
let { blogTitle }: Props = $props();
9
9
+
let { blogTitle }: Props = $props();
10
10
11
11
-
const comments = getBlogPostComments(blogTitle);
11
11
+
const comments = getBlogPostComments(blogTitle);
12
12
</script>
13
13
14
14
<section class="bluesky-comments">
15
15
-
<h2>Comments 🗣️</h2>
15
15
+
<h2>Comments 🗣️</h2>
16
16
17
17
-
{#await comments}
18
18
-
<p>Loading comments... ⏰</p>
19
19
-
{:then comments}
20
20
-
{#each comments as comment}
21
21
-
<article
22
22
-
class="comment"
23
23
-
aria-labelledby="comment-{comment.cid}-author"
17
17
+
{#await comments}
18
18
+
<p>Loading comments... ⏰</p>
19
19
+
{:then comments}
20
20
+
{#each comments as comment}
21
21
+
<article class="comment" aria-labelledby="comment-{comment.cid}-author">
22
22
+
<header>
23
23
+
<h2 class="comment-author" id="comment-{comment.cid}-author">
24
24
+
<a
25
25
+
href={`https://bsky.app/profile/${comment.author.did}`}
26
26
+
rel="noopener noreferrer"
27
27
+
target="_blank"
28
28
+
aria-label="{comment.author.displayName}'s profile on Bluesky"
24
29
>
25
25
-
<header>
26
26
-
<h2
27
27
-
class="comment-author"
28
28
-
id="comment-{comment.cid}-author"
29
29
-
>
30
30
-
<a
31
31
-
href={`https://bsky.app/profile/${comment.author.did}`}
32
32
-
rel="noopener noreferrer"
33
33
-
target="_blank"
34
34
-
aria-label="{comment.author
35
35
-
.displayName}'s profile on Bluesky"
36
36
-
>
37
37
-
{comment.author.displayName}
38
38
-
<span class="handle"
39
39
-
>(@{comment.author.handle})</span
40
40
-
>
41
41
-
</a>
42
42
-
<time
43
43
-
class="comment-time"
44
44
-
aria-label="Commented on"
45
45
-
datetime={comment.record.createdAt}
46
46
-
>
47
47
-
{formatDate(new Date(comment.record.createdAt))}
48
48
-
</time>
49
49
-
</h2>
50
50
-
</header>
51
51
-
<p class="comment-body">{comment.record.text}</p>
52
52
-
<footer class="comment-counts">
53
53
-
<a
54
54
-
href={`https://bsky.app/profile/${comment.author.did}`}
55
55
-
rel="noopener noreferrer"
56
56
-
target="_blank"
57
57
-
>
58
58
-
<p class="likes">
59
59
-
<iconify-icon
60
60
-
icon={"fa6-solid:heart"}
61
61
-
height={"1rem"}
62
62
-
></iconify-icon>
63
63
-
{comment.likeCount} Likes
64
64
-
</p>
65
65
-
<p class="replies">
66
66
-
<iconify-icon
67
67
-
icon={"fa6-solid:comment"}
68
68
-
height={"1rem"}
69
69
-
></iconify-icon>
70
70
-
{comment.replyCount} Replies
71
71
-
</p>
72
72
-
<p class="replies">
73
73
-
<iconify-icon
74
74
-
icon={"fa6-solid:repeat"}
75
75
-
height={"1rem"}
76
76
-
></iconify-icon>
77
77
-
{comment.quoteCount} Quotes
78
78
-
</p>
79
79
-
</a>
80
80
-
</footer>
81
81
-
</article>
82
82
-
{:else}
83
83
-
<p>No comments just yet 🐄</p>
84
84
-
{/each}
85
85
-
{:catch}
86
86
-
<div>
87
87
-
<p>There was an error getting the comments! ⚠️</p>
88
88
-
<p>
89
89
-
Please <a href="mailto:me@claycow.com">reach out</a> if this persists.
90
90
-
❤️
30
30
+
{comment.author.displayName}
31
31
+
<span class="handle">(@{comment.author.handle})</span>
32
32
+
</a>
33
33
+
<time
34
34
+
class="comment-time"
35
35
+
aria-label="Commented on"
36
36
+
datetime={comment.record.createdAt}
37
37
+
>
38
38
+
{formatDate(new Date(comment.record.createdAt))}
39
39
+
</time>
40
40
+
</h2>
41
41
+
</header>
42
42
+
<p class="comment-body">{comment.record.text}</p>
43
43
+
<footer class="comment-counts">
44
44
+
<a
45
45
+
href={`https://bsky.app/profile/${comment.author.did}`}
46
46
+
rel="noopener noreferrer"
47
47
+
target="_blank"
48
48
+
>
49
49
+
<p class="likes">
50
50
+
<iconify-icon icon={"fa6-solid:heart"} height={"1rem"}
51
51
+
></iconify-icon>
52
52
+
{comment.likeCount} Likes
91
53
</p>
92
92
-
</div>
93
93
-
{/await}
54
54
+
<p class="replies">
55
55
+
<iconify-icon icon={"fa6-solid:comment"} height={"1rem"}
56
56
+
></iconify-icon>
57
57
+
{comment.replyCount} Replies
58
58
+
</p>
59
59
+
<p class="replies">
60
60
+
<iconify-icon icon={"fa6-solid:repeat"} height={"1rem"}
61
61
+
></iconify-icon>
62
62
+
{comment.quoteCount} Quotes
63
63
+
</p>
64
64
+
</a>
65
65
+
</footer>
66
66
+
</article>
67
67
+
{:else}
68
68
+
<p>No comments just yet 🐄</p>
69
69
+
{/each}
70
70
+
{:catch}
71
71
+
<div>
72
72
+
<p>There was an error getting the comments! ⚠️</p>
73
73
+
<p>
74
74
+
Please <a href="mailto:me@claycow.com">reach out</a> if this persists. ❤️
75
75
+
</p>
76
76
+
</div>
77
77
+
{/await}
94
78
</section>
95
79
96
80
<style>
97
97
-
.bluesky-comments {
98
98
-
display: flex;
99
99
-
flex-direction: column;
100
100
-
gap: 1rem;
101
101
-
}
81
81
+
.bluesky-comments {
82
82
+
display: flex;
83
83
+
flex-direction: column;
84
84
+
gap: 1rem;
85
85
+
}
102
86
103
103
-
.bluesky-comments > h2 {
104
104
-
margin-bottom: 0;
105
105
-
}
87
87
+
.bluesky-comments > h2 {
88
88
+
margin-bottom: 0;
89
89
+
}
106
90
107
107
-
.bluesky-comments > article {
108
108
-
background-color: var(--surface0);
109
109
-
padding: 1rem;
110
110
-
border-radius: 0.5rem;
111
111
-
}
91
91
+
.bluesky-comments > article {
92
92
+
background-color: var(--surface0);
93
93
+
padding: 1rem;
94
94
+
border-radius: 0.5rem;
95
95
+
}
112
96
113
113
-
.comment-author {
114
114
-
display: flex;
115
115
-
flex-direction: row;
116
116
-
font-size: medium;
117
117
-
margin: 0;
118
118
-
}
97
97
+
.comment-author {
98
98
+
display: flex;
99
99
+
flex-direction: row;
100
100
+
font-size: medium;
101
101
+
margin: 0;
102
102
+
}
119
103
120
120
-
.comment-author > a {
121
121
-
flex-grow: 1;
122
122
-
text-decoration: none;
123
123
-
color: var(--text);
124
124
-
}
104
104
+
.comment-author > a {
105
105
+
flex-grow: 1;
106
106
+
text-decoration: none;
107
107
+
color: var(--text);
108
108
+
}
125
109
126
126
-
.comment-author > a > .handle {
127
127
-
color: var(--subtext0);
128
128
-
}
110
110
+
.comment-author > a > .handle {
111
111
+
color: var(--subtext0);
112
112
+
}
129
113
130
130
-
.comment-author > .comment-time {
131
131
-
color: var(--subtext0);
132
132
-
font-size: x-small;
133
133
-
}
114
114
+
.comment-author > .comment-time {
115
115
+
color: var(--subtext0);
116
116
+
font-size: x-small;
117
117
+
}
134
118
135
135
-
.comment-body {
136
136
-
margin: 1rem 0 0;
137
137
-
}
119
119
+
.comment-body {
120
120
+
margin: 1rem 0 0;
121
121
+
}
138
122
139
139
-
.comment-counts > a {
140
140
-
display: flex;
141
141
-
flex-direction: row;
142
142
-
gap: 2rem;
143
143
-
text-decoration: none;
144
144
-
color: var(--text);
145
145
-
}
123
123
+
.comment-counts > a {
124
124
+
display: flex;
125
125
+
flex-direction: row;
126
126
+
gap: 2rem;
127
127
+
text-decoration: none;
128
128
+
color: var(--text);
129
129
+
}
146
130
147
147
-
.comment-counts > a > p {
148
148
-
display: flex;
149
149
-
flex-direction: row;
150
150
-
align-items: center;
151
151
-
gap: 0.5rem;
152
152
-
margin-bottom: 0;
153
153
-
}
131
131
+
.comment-counts > a > p {
132
132
+
display: flex;
133
133
+
flex-direction: row;
134
134
+
align-items: center;
135
135
+
gap: 0.5rem;
136
136
+
margin-bottom: 0;
137
137
+
}
154
138
</style>
+3
-3
src/utils/getBlogPostComments.ts
reviewed
···
5
5
6
6
async function getBlogPostComments(blogTitle: string) {
7
7
8
8
-
const agent = new AtpAgent({ service: new URL("https://public.api.bsky.app") })
8
8
+
const agent = new AtpAgent({ service: new URL("https://api.bsky.app") });
9
9
10
10
const post = await agent.app.bsky.feed.searchPosts({
11
11
-
q: `from:claycow.com #blog #${formatBlogTitleUrl(blogTitle)}`,
11
11
+
q: `#blog #${formatBlogTitleUrl(blogTitle)}`,
12
12
author: BLUESKY_DID,
13
13
limit: 1
14
14
}).then(({ data }) => {
···
48
48
return comments;
49
49
}
50
50
51
51
-
export default getBlogPostComments;
51
51
+
export default getBlogPostComments;