{{ $url := .Get "url" }} {{ $title := .Get "title" }} {{ $description := .Get "description" }} {{ $image := .Get "image" }} {{ $favicon := .Get "favicon" }} {{ $provider := .Get "provider" }} {{ $noFetch := .Get "noFetch" | default false }} {{ $cardClasses := "flex flex-col md:flex-row relative overflow-hidden rounded-lg border border-neutral-300 dark:border-neutral-600 hover:border-neutral-400 dark:hover:border-neutral-500 transition-colors not-prose" }} {{ $parsedURL := urls.Parse $url }} {{ $domain := $parsedURL.Host }} {{ $fetchedTitle := "" }} {{ $fetchedDescription := "" }} {{ $fetchedImage := "" }} {{ $fetchedFavicon := "" }} {{ $fetchedProvider := "" }} {{ if and (not $noFetch) $url }} {{ with resources.GetRemote $url }} {{ $content := .Content }} {{ $ogTitleTags := findRE `]+property=["']og:title["'][^>]*>` $content 1 }} {{ with index $ogTitleTags 0 }} {{ $fetchedTitle = . | replaceRE `.*content=["']([^"']*)["'].*` `$1` }} {{ end }} {{ $ogDescTags := findRE `]+property=["']og:description["'][^>]*>` $content 1 }} {{ with index $ogDescTags 0 }} {{ $fetchedDescription = . | replaceRE `.*content=["']([^"']*)["'].*` `$1` }} {{ end }} {{ $ogImageTags := findRE `]+property=["']og:image["'][^>]*>` $content 1 }} {{ with index $ogImageTags 0 }} {{ $fetchedImage = . | replaceRE `.*content=["']([^"']*)["'].*` `$1` }} {{ end }} {{ $ogSiteNameTags := findRE `]+property=["']og:site_name["'][^>]*>` $content 1 }} {{ with index $ogSiteNameTags 0 }} {{ $fetchedProvider = . | replaceRE `.*content=["']([^"']*)["'].*` `$1` }} {{ end }} {{ end }} {{ end }} {{ $finalTitle := default $fetchedTitle $title }} {{ $finalDescription := default $fetchedDescription $description }} {{ $finalImage := default $fetchedImage $image }} {{ $finalFavicon := default $fetchedFavicon $favicon }} {{ $finalProvider := default $fetchedProvider $provider }} {{ if not $finalProvider }} {{ $finalProvider = $domain }} {{ end }} {{ if not $finalFavicon }} {{ $finalFavicon = printf "https://%s/favicon.ico" $domain }} {{ end }} {{ with $finalImage }}
{{ $finalTitle }}
{{ end }}

{{ $finalTitle | default $domain }}

{{ with $finalDescription }}

{{ . }}

{{ end }}
{{ with $finalFavicon }} {{ end }} {{ $finalProvider }}