{{/* Contributors Page Content */}}
{{/* Support both direct context and dict with context/repoKey */}}
{{ $context := . }}
{{ $repoKey := "" }}
{{ if reflect.IsMap . }}
  {{ with .context }}{{ $context = . }}{{ end }}
  {{ with .repoKey }}{{ $repoKey = . }}{{ end }}
{{ end }}
{{ $data := partial "load-metrics.html" (dict "context" $context "repoKey" $repoKey) }}
{{ $m := $data.metrics }}
{{ $contributors := $data.contributors }}

{{ if not $m }}
<div class="alert alert-warning">
  <span>No data available. Run the aggregation script.</span>
</div>
{{ else }}

<!-- Overview -->
<section class="mb-6">
  <h2 class="text-sm font-semibold mb-3">Overview</h2>
  <div class="grid grid-cols-3 gap-3">
    {{ partial "metric-card.html" (dict "label" "Total Contributors" "value" $m.contributors.total_known "subtext" "All-time unique") }}
    {{ partial "metric-card.html" (dict "label" "Active (30 days)" "value" $m.contributors.active_30d "subtext" "Recent activity") }}
    {{ partial "metric-card.html" (dict "label" "First-time (30 days)" "value" $m.contributors.first_time_30d "subtext" "New this month") }}
  </div>
</section>

<!-- Maintainers -->
{{ $maintainers := site.Data.maintainers }}
{{ if $maintainers }}
<section class="mb-6">
  <h2 class="text-sm font-semibold mb-1">Maintainers</h2>
  <p class="text-xs text-base-content/50 mb-3">{{ len $maintainers.maintainers }} maintainers from <code class="text-xs bg-base-200 px-1 rounded">modelcontextprotocol/access</code></p>
  <div class="overflow-x-auto rounded-lg border border-base-300 bg-base-100">
    <table class="table table-sm table-bordered w-full">
      <thead>
        <tr>
          <th class="bg-base-200">GitHub ID</th>
          <th class="bg-base-200">Roles</th>
        </tr>
      </thead>
      <tbody>
        {{ range $maintainers.maintainers }}
        <tr>
          <td>
            <a href="https://github.com/{{ .github }}" target="_blank" rel="noopener" class="text-primary hover:underline">
              @{{ .github }}
            </a>
          </td>
          <td>
            <div class="flex flex-wrap gap-1">
              {{ range .roles }}
              <span class="badge badge-sm">{{ . }}</span>
              {{ end }}
            </div>
          </td>
        </tr>
        {{ end }}
      </tbody>
    </table>
  </div>
</section>
{{ end }}

{{ end }}
