Skip to content

Commit b76ba2a

Browse files
committed
fix: get backlinks working
1 parent 391c883 commit b76ba2a

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

app/composables/useBlogPostBlueskyLink.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Constellation } from '#shared/utils/constellation'
2-
// import { NPMX_SITE } from '#shared/utils/constants'
3-
4-
const BLOG_BACKLINK_TTL_IN_SECONDS = 60 * 5
2+
import { NPMX_SITE } from '#shared/utils/constants'
53

64
export interface BlogPostBlueskyLink {
75
did: string
@@ -15,9 +13,7 @@ export function useBlogPostBlueskyLink(slug: MaybeRefOrGetter<string | null | un
1513
const blogUrl = computed(() => {
1614
const s = toValue(slug)
1715
if (!s) return null
18-
// return `${NPMX_SITE}/blog/${s}`
19-
// TODO: Deploy Preview used for testing remove before merge
20-
return `https://npmxdev-git-fork-jonathanyeong-feat-atproto-blog-fe-poetry.vercel.app/blog/${s}`
16+
return `${NPMX_SITE}/blog/${s}`
2117
})
2218

2319
return useLazyAsyncData<BlogPostBlueskyLink | null>(
@@ -34,14 +30,10 @@ export function useBlogPostBlueskyLink(slug: MaybeRefOrGetter<string | null | un
3430
url,
3531
'app.bsky.feed.post',
3632
'embed.external.uri',
37-
1,
38-
undefined,
39-
false,
40-
[['did:plc:5ixnpdbogli5f7fbbee5fmuq']],
41-
BLOG_BACKLINK_TTL_IN_SECONDS,
33+
[['did:plc:jbeaa5kdaladzwq3r7f5xgwe']],
4234
)
4335

44-
const embedRecord = embedBacklinks.records[0]
36+
const embedRecord = embedBacklinks.records[embedBacklinks.records.length - 1]
4537
if (embedRecord) {
4638
return {
4739
did: embedRecord.did,
@@ -54,15 +46,11 @@ export function useBlogPostBlueskyLink(slug: MaybeRefOrGetter<string | null | un
5446
const { data: facetBacklinks } = await constellation.getBackLinks(
5547
url,
5648
'app.bsky.feed.post',
57-
'facets.features.uri',
58-
1,
59-
undefined,
60-
false,
61-
[],
62-
BLOG_BACKLINK_TTL_IN_SECONDS,
49+
'facets[].features[app.bsky.richtext.facet#link].uri',
50+
[['did:plc:jbeaa5kdaladzwq3r7f5xgwe']],
6351
)
6452

65-
const facetRecord = facetBacklinks.records[0]
53+
const facetRecord = facetBacklinks.records[facetBacklinks.records.length - 1]
6654
if (facetRecord) {
6755
return {
6856
did: facetRecord.did,

shared/utils/constellation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ export class Constellation {
5757
subject: string,
5858
collection: string,
5959
recordPath: string,
60+
filterByDids: [string][] = [],
6061
limit = 16,
6162
cursor?: string,
6263
reverse = false,
63-
filterByDids: [string][] = [],
6464
ttl: number | undefined = undefined,
6565
) {
6666
const source = encodeURIComponent(`${collection}:${recordPath}`)

0 commit comments

Comments
 (0)