{% extends "base.html" %}
{% block title %}Wanted pages — Wiki{% endblock %}
{% block content %}
{% include "wiki/_layout.html" %}

<div class="bbs-header">
    <h1><i class="bi bi-question-circle"></i> Wanted pages</h1>
    <p class="text-muted">Pages that other pages link to but which haven't been created yet.</p>
</div>

{% if items %}
<div class="card">
    <table class="table table-sm mb-0">
        <thead>
            <tr><th>Slug</th><th class="text-end">Incoming links</th><th></th></tr>
        </thead>
        <tbody>
        {% for slug, count in items %}
        <tr>
            <td><code>{{ slug }}</code></td>
            <td class="text-end"><span class="badge bg-secondary">{{ count }}</span></td>
            <td>
                {% if current_user.is_authenticated %}
                <a href="{{ url_for('wiki.edit', slug=slug) }}" class="btn btn-sm btn-outline-primary">
                    <i class="bi bi-pencil"></i> Create
                </a>
                {% else %}
                <a href="{{ url_for('wiki.view', slug=slug) }}">view</a>
                {% endif %}
            </td>
        </tr>
        {% endfor %}
        </tbody>
    </table>
</div>
{% else %}
<div class="alert alert-success">
    <i class="bi bi-check-circle"></i> Every linked page exists. Nice.
</div>
{% endif %}
{% endblock %}
