Bluesky app fork with some witchin' additions 💫

[Embeds] Add ref_url (#3533)

* get outer location and pass in to the iframe

* enable post.html in dev

* only add ref_url if starts with http

* Revert "enable post.html in dev"

This reverts commit 6f224c6e2c4a016f7ea17ff998c4b4e56b9a4f9b.

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>

authored by samuel.fm

Dan Abramov and committed by
GitHub
1a9eeb76 4c95ec2e

+17 -1
+11 -1
bskyembed/snippet/embed.ts
··· 59 59 continue 60 60 } 61 61 62 + const ref_url = location.origin + location.pathname 63 + 64 + const searchParams = new URLSearchParams() 65 + searchParams.set('id', id) 66 + if (ref_url.startsWith('http')) { 67 + searchParams.set('ref_url', encodeURIComponent(ref_url)) 68 + } 69 + 62 70 const iframe = document.createElement('iframe') 63 71 iframe.setAttribute('data-bluesky-id', id) 64 - iframe.src = `${EMBED_URL}/embed/${aturi.slice('at://'.length)}?id=${id}` 72 + iframe.src = `${EMBED_URL}/embed/${aturi.slice( 73 + 'at://'.length, 74 + )}?${searchParams.toString()}` 65 75 iframe.width = '100%' 66 76 iframe.style.border = 'none' 67 77 iframe.style.display = 'block'
+6
bskyembed/src/components/link.tsx
··· 8 8 href: string 9 9 className?: string 10 10 } & h.JSX.HTMLAttributes<HTMLAnchorElement>) { 11 + const searchParam = new URLSearchParams(window.location.search) 12 + const ref_url = searchParam.get('ref_url') 13 + 11 14 const newSearchParam = new URLSearchParams() 12 15 newSearchParam.set('ref_src', 'embed') 16 + if (ref_url) { 17 + newSearchParam.set('ref_url', ref_url) 18 + } 13 19 14 20 return ( 15 21 <a