Skip to content

Commit e4b10c9

Browse files
committed
refactor: rename useAuthorProfiles to useBlueskyAuthorProfiles for clarity
Add a comment to hopefully clarify how useBlueskyAuthorProfiles works with the bluesky-author-profiles server end point.
1 parent b316bad commit e4b10c9

File tree

5 files changed

+38
-32
lines changed

5 files changed

+38
-32
lines changed

app/components/AuthorList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const props = defineProps<{
66
variant?: 'compact' | 'expanded'
77
}>()
88
9-
const { resolvedAuthors } = useAuthorProfiles(props.authors)
9+
const { resolvedAuthors } = useBlueskyAuthorProfiles(props.authors)
1010
</script>
1111

1212
<template>

app/components/OgImage/BlogPost.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const props = withDefaults(
1515
},
1616
)
1717
18-
const { resolvedAuthors } = useAuthorProfiles(props.authors)
18+
const { resolvedAuthors } = useBlueskyAuthorProfiles(props.authors)
1919
2020
const formattedDate = computed(() => {
2121
if (!props.date) return ''

app/composables/useAuthorProfiles.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { Author, ResolvedAuthor } from '#shared/schemas/blog'
2+
3+
/**
4+
* Fetches author avatar URLs and profile links from the Bluesky API (AT Protocol).
5+
*
6+
* Makes a server-side request to `/api/atproto/bluesky-author-profiles`, which looks up
7+
* each author's Bluesky profile to retrieve their avatar. Results are cached for 1 day.
8+
*
9+
* While the fetch is pending (or if it fails), returns authors with `avatar: null`
10+
* and a constructed profile URL as fallback.
11+
*/
12+
export function useBlueskyAuthorProfiles(authors: Author[]) {
13+
const authorsJson = JSON.stringify(authors)
14+
15+
const { data } = useFetch('/api/atproto/bluesky-author-profiles', {
16+
query: {
17+
authors: authorsJson,
18+
},
19+
})
20+
21+
const resolvedAuthors = computed<ResolvedAuthor[]>(
22+
() => data.value?.authors ?? withoutBlueskyData(authors),
23+
)
24+
25+
return {
26+
resolvedAuthors,
27+
}
28+
}
29+
30+
function withoutBlueskyData(authors: Author[]): ResolvedAuthor[] {
31+
return authors.map(author => ({
32+
...author,
33+
avatar: null,
34+
profileUrl: author.blueskyHandle ? `https://bsky.app/profile/${author.blueskyHandle}` : null,
35+
}))
36+
}
File renamed without changes.

0 commit comments

Comments
 (0)