{{ define "repo/fragments/backlinks" }}
  {{ if .Backlinks }}
  <div id="at-uri-panel" class="px-2 md:px-0">
    <div>
      <span class="text-sm py-1 font-bold text-gray-500 dark:text-gray-400">Referenced by</span>
    </div>
    <ul>
      {{ range .Backlinks }}
      <li>
        {{ $repoOwner := resolve .Handle }}
        {{ $repoName := .Repo }}
        {{ $repoUrl := printf "%s/%s" $repoOwner $repoName }}
        <div class="flex flex-col">
          <div class="flex gap-2 items-center">
            {{ if .State.IsClosed }}
              <span class="text-gray-500 dark:text-gray-400">
                {{ i "ban" "size-3" }}
              </span>
            {{ else if eq .Kind.String "issues" }}
              <span class="text-green-600 dark:text-green-500">
                {{ i "circle-dot" "size-3" }}
              </span>
            {{ else if .State.IsOpen }}
              <span class="text-green-600 dark:text-green-500">
                {{ i "git-pull-request" "size-3" }}
              </span>
            {{ else if .State.IsMerged }}
              <span class="text-purple-600 dark:text-purple-500">
                {{ i "git-merge" "size-3" }}
              </span>
            {{ else }}
              <span class="text-gray-600 dark:text-gray-300">
                {{ i "git-pull-request-closed" "size-3" }}
              </span>
            {{ end }}
            <a href="/{{ $repoUrl }}/{{ .Kind }}/{{ .SubjectId }}{{ with .CommentRkey }}#comment-{{.}}{{end}}" class="line-clamp-1 text-sm"><span class="text-gray-500 dark:text-gray-400">#{{ .SubjectId }}</span> {{ .Title }}</a>
          </div>
          {{ if not (eq $.RepoInfo.FullName $repoUrl) }}
          <div>
            <span>on <a href="/{{ $repoUrl }}">{{ $repoUrl }}</a></span>
          </div>
          {{ end }}
        </div>
      </li>
      {{ end }}
    </ul>
  </div>
  {{ end }}
{{ end }}
