---
import type * as interfaces from '../../lib/interfaces.ts'
import { isAmazonURL, isGitHubURL } from '../../lib/blog-helpers.ts'
import GithubLinkPreview from './GitHubLinkPreview.astro'
import Caption from './Caption.astro'
export interface Props {
block: interfaces.Block
urlMap: { [key: string]: string }
}
const { block } = Astro.props
const target = block.Bookmark || block.LinkPreview || block.Embed
const urlString = target?.Url
let url: URL | null = null
try {
if (urlString) {
url = new URL(urlString)
}
} catch (err) {
console.log(err)
}
---
{
url && (
<>
{block.LinkPreview && isGitHubURL(url) ? (