{% extends "admin/blank.twig" %}
{% block content %}
<h1 class="text-2xl font-bold mb-6">Contents List</h1>
<a href="/admin/contents/create" class="bg-blue-500 text-white px-4 py-2 rounded mb-4 inline-block">Add New</a>
<table class="min-w-full bg-white">
    <thead>
        <tr>
            <th class="py-2 px-4 border-b">ID</th>
            <th class="py-2 px-4 border-b">Key</th>
            <th class="py-2 px-4 border-b">Content</th>
            <th class="py-2 px-4 border-b">Actions</th>
        </tr>
    </thead>
    <tbody>
        {% for content in contents %}
        <tr>
            <td class="py-2 px-4 border-b">{{ content.id }}</td>
            <td class="py-2 px-4 border-b">{{ content.key }}</td>
            <td class="py-2 px-4 border-b">
                {{ content.content|length > 80 ? content.content[:80] ~ '...' : content.content }}
            </td>
            <td class="py-2 px-4 border-b">
                <a href="/admin/contents/edit/{{ content.id }}" class="text-blue-600 hover:underline">Edit</a>
                <a href="/admin/contents/delete/{{ content.id }}" class="text-red-600 hover:underline ml-2" onclick="return confirm('Are you sure you want to delete this content?');">Delete</a>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endblock %}
