{% load static %}
{% load i18n %}

<!-- base.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <title>{% block title %}{{ meta.brand }}{% endblock %}</title>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="referrer" content="strict-origin-when-cross-origin" />
    <meta name="description" content="{{ meta.description }}">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="all,follow">
    <meta property="og:site_name" content="Blogbeat" />
    <meta property="og:title" content="{{ meta.brand }}" />
    <meta property="og:description" content="{{ meta.description }}" />
    <meta property="og:image" content="{{ meta.logo }}" />
    <meta property="og:url" content="{% url 'frontend' %}" />
    <meta property="og:type" content="{{ meta.type|default_if_none:"website" }}" />

    <link rel="shortcut icon" href="{% static 'img/blogbeat-logo.png' %}">
    <link rel="apple-touch-icon" href="{% static 'img/blogbeat-logo.png' %}">

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <link rel="stylesheet" href="{% static meta.css %}">
<body>

<header>
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <div class="container">
            <img style="max-height: 35px; margin-right: 10px" src="{% static meta.logo %}" />
            <a class="navbar-brand" href="{% url 'frontend' %}">{{ meta.brand }}</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    {% for app_name, app in meta.navbar.items %}
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" id="{{ app }}-dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                                {{ app.verbose_name }}
                            </a>
                            <ul class="dropdown-menu" aria-labelledby="{{ app }}-dropdown">
                                <li><a class="dropdown-item" href="{% url 'frontend' app_name=app_name  %}">All {{ app.verbose_name }}</a></li>
                                {% for model in app.models %}
                                    <li><a class="dropdown-item" href="{% url 'frontend' app_name=app_name model_name=model.name  %}">{{ model.verbose_name }}</a></li>
                                {% endfor %}
                            </ul>
                        </li>
                    {% endfor %}
                </ul>
            </div>
        </div>
    </nav>
</header>

{% for message in messages %}
    <div class="container-fluid p-0">
        <div class="alert {{ message.tags }} alert-dismissible" role="alert" >
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <span aria-hidden="True">&times;</span>
            </button>
            {{ message }}
        </div>
    </div>
{% endfor %}
{% for errors in form.non_field_errors %}
    <div class="container-fluid p-0">
        <div class="alert alert-danger alert-dismissible" role="alert" >
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <span aria-hidden="True">&times;</span>
            </button>
            {{ errors }}
        </div>
    </div>
{% endfor %}

<main class="container mt-3">
    {% block content %}
    {% endblock %}
</main>

<footer>
    <!-- Add your footer content here -->
</footer>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script>
</body>
</html>
