Skip to content

Commit 348dd1d

Browse files
authored
fix(bluesky): expand allowed Post types (#67)
* fix(bluesky): expand allowed Post types * Chanegset
1 parent ff70195 commit 348dd1d

File tree

7 files changed

+255
-164
lines changed

7 files changed

+255
-164
lines changed

.changeset/bright-ladybugs-deliver.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ascorbic/bluesky-loader": patch
3+
---
4+
5+
Correctly handle all post types

demos/loaders/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@ascorbic/csv-loader": "workspace:^",
1717
"@ascorbic/feed-loader": "workspace:^",
1818
"@ascorbic/mock-loader": "workspace:^",
19+
"@astro-community/astro-embed-bluesky": "^0.1.1",
1920
"@astrojs/check": "^0.9.4",
2021
"@astrojs/netlify": "^5.5.4",
2122
"@atproto/api": "^0.13.14",

demos/loaders/src/pages/bluesky.astro

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
import { getCollection, render } from "astro:content";
3-
import { AppBskyEmbedImages, AppBskyEmbedRecordWithMedia } from "@atproto/api";
2+
import { getCollection } from "astro:content";
3+
import { BlueskyPost } from "@astro-community/astro-embed-bluesky";
44
55
const posts = await getCollection("bluesky");
66
---
@@ -13,54 +13,19 @@ const posts = await getCollection("bluesky");
1313
<body>
1414
<h1>Bluesky</h1>
1515
{
16-
posts.map(async (post) => {
17-
const { Content } = await render(post);
18-
const { embed } = post.data;
19-
return (
20-
<section>
21-
<Content />
22-
<p>{post.data.likeCount} likes</p>
23-
24-
<div>
25-
{AppBskyEmbedImages.isView(embed)
26-
? embed?.images.map(
27-
(image) =>
28-
image && <img src={image.thumb} alt={image.alt} />
29-
)
30-
: undefined}
31-
{AppBskyEmbedRecordWithMedia.isView(embed) &&
32-
embed.media.external.uri ? (
33-
<img
34-
src={embed.media.external.uri}
35-
alt={embed.media.external.description}
36-
/>
37-
) : undefined}
38-
</div>
39-
</section>
40-
);
41-
})
16+
posts
17+
.sort(
18+
(a, b) =>
19+
new Date(b.data.record.createdAt).getTime() -
20+
new Date(a.data.record.createdAt).getTime()
21+
)
22+
.map(async (post) => {
23+
return (
24+
<section>
25+
<BlueskyPost post={post.data} />
26+
</section>
27+
);
28+
})
4229
}
43-
<style>
44-
* {
45-
font-family:
46-
system-ui,
47-
-apple-system,
48-
BlinkMacSystemFont,
49-
"Segoe UI",
50-
Roboto,
51-
Oxygen,
52-
Ubuntu,
53-
Cantarell,
54-
"Open Sans",
55-
"Helvetica Neue",
56-
sans-serif;
57-
}
58-
section {
59-
background-color: white;
60-
box-shadow: 0 0 1rem rgba(0, 0, 0, 0.4);
61-
margin: 1rem 0;
62-
padding: 1rem;
63-
}
64-
</style>
6530
</body>
6631
</html>

demos/loaders/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "astro/tsconfigs/strictest"
2+
"extends": "astro/tsconfigs/strict",
3+
"compilerOptions": {
4+
"noErrorTruncation": true
5+
}
36
}

packages/bluesky/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ export const authorFeedLoader = ({
4040
for (const { post } of data.feed) {
4141
if (
4242
(mostRecent && mostRecent === post.cid) ||
43-
(limit && count++ >= limit)
43+
(limit && count >= limit)
4444
) {
45+
count++;
4546
break fetching;
4647
}
48+
count++;
4749
if (!first) {
4850
first = post.cid;
4951
}
@@ -61,6 +63,7 @@ export const authorFeedLoader = ({
6163
});
6264
}
6365
cursor = data.cursor;
66+
logger.info(`Fetched ${count} posts`);
6467
} while (cursor);
6568

6669
if (first) {

0 commit comments

Comments
 (0)