[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 6f224c6e2c.
---------
Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
This commit is contained in:
@@ -59,9 +59,19 @@ function scan(node = document) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ref_url = location.origin + location.pathname
|
||||||
|
|
||||||
|
const searchParams = new URLSearchParams()
|
||||||
|
searchParams.set('id', id)
|
||||||
|
if (ref_url.startsWith('http')) {
|
||||||
|
searchParams.set('ref_url', encodeURIComponent(ref_url))
|
||||||
|
}
|
||||||
|
|
||||||
const iframe = document.createElement('iframe')
|
const iframe = document.createElement('iframe')
|
||||||
iframe.setAttribute('data-bluesky-id', id)
|
iframe.setAttribute('data-bluesky-id', id)
|
||||||
iframe.src = `${EMBED_URL}/embed/${aturi.slice('at://'.length)}?id=${id}`
|
iframe.src = `${EMBED_URL}/embed/${aturi.slice(
|
||||||
|
'at://'.length,
|
||||||
|
)}?${searchParams.toString()}`
|
||||||
iframe.width = '100%'
|
iframe.width = '100%'
|
||||||
iframe.style.border = 'none'
|
iframe.style.border = 'none'
|
||||||
iframe.style.display = 'block'
|
iframe.style.display = 'block'
|
||||||
|
|||||||
@@ -8,8 +8,14 @@ export function Link({
|
|||||||
href: string
|
href: string
|
||||||
className?: string
|
className?: string
|
||||||
} & h.JSX.HTMLAttributes<HTMLAnchorElement>) {
|
} & h.JSX.HTMLAttributes<HTMLAnchorElement>) {
|
||||||
|
const searchParam = new URLSearchParams(window.location.search)
|
||||||
|
const ref_url = searchParam.get('ref_url')
|
||||||
|
|
||||||
const newSearchParam = new URLSearchParams()
|
const newSearchParam = new URLSearchParams()
|
||||||
newSearchParam.set('ref_src', 'embed')
|
newSearchParam.set('ref_src', 'embed')
|
||||||
|
if (ref_url) {
|
||||||
|
newSearchParam.set('ref_url', ref_url)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
|
|||||||
Reference in New Issue
Block a user