{{ define "repo/fragments/og" }}
    {{ $title := or .Title .RepoInfo.FullName }}
    {{ $description := or .RepoInfo.Description "A repository on Tangled" }}
    {{ $url := or .Url (printf "https://tangled.org/%s" .RepoInfo.FullName) }}
    {{ $imageUrl := printf "https://tangled.org/%s/opengraph" .RepoInfo.FullName }}
    {{ $ownerHandle := resolve .RepoInfo.OwnerDid }}

    <!-- Open Graph Meta Tags -->
    <meta property="og:title" content="{{ unescapeHtml $title }}" />
    <meta property="og:type" content="article" />
    <meta property="og:url" content="{{ $url }}" />
    <meta property="og:description" content="{{ $description }}" />
    <meta property="og:image" content="{{ $imageUrl }}" />
    <meta property="og:image:width" content="1200" />
    <meta property="og:image:height" content="600" />
    <meta property="og:image:alt" content="{{ unescapeHtml $title }}" />
    <meta property="article:author" content="{{ $ownerHandle }}" />
    {{ if .RepoInfo.Topics }}
        {{ range .RepoInfo.Topics }}
    <meta property="article:tag" content="{{ . }}" />
        {{ end }}
    {{ end }}

    <!-- Twitter Card Meta Tags -->
    <meta name="twitter:card" content="summary_large_image" />
    <meta name="twitter:title" content="{{ unescapeHtml $title }}" />
    <meta name="twitter:description" content="{{ $description }}" />
    <meta name="twitter:image" content="{{ $imageUrl }}" />
    <meta name="twitter:image:alt" content="{{ unescapeHtml $title }}" />

    <!-- Additional SEO -->
    <meta name="description" content="{{ $description }}" />
    <link rel="canonical" href="{{ $url }}" />
{{ end }}
