{% extends "./base.html" %}
{% load i18n %}
{% load static %}

{% load wagtailcore_tags %}
{% load wagtailimages_tags %}

{% load django_vite %}

{% if page.comments_enabled %}
  {% load comments %}
{% endif %}

{% block css %}
  {{ block.super }}
  {% if page.comments_are_enabled %}
    <link rel="stylesheet" type="text/css" href="{% static 'fluent_comments/css/ajaxcomments.css' %}" />
  {% endif %}
{% endblock css %}

{% block meta %}
  {{ block.super }}
  {% if page.blog.noindex %}
    <meta name="robots" content="noindex">
  {% endif %}
{% endblock %}

{% block body_class %}template-blogpage{% endblock %}

{% block title %}{{ page.title }}{% endblock title %}

{% block content %}
  {% include "./post_body.html" with render_detail=True %}

  {% if page.comments_are_enabled %}
    {% render_comment_list for page %}
    {% render_comment_form for page %}
  {% endif %}


  <p><a href="{{ page.get_parent.url }}">Return to blog</a></p>

{% endblock %}

{% block javascript %}
  {{ block.super }}
  {% vite_hmr_client app="cast" %}
  {% vite_asset 'src/gallery/image-gallery-bs4.ts' app="cast" %}

  <!-- full query is needed for comments -->
  <script defer src="{% static 'cast/js/jquery/jquery-3.7.1.min.js' %}"></script>
  <script defer type="text/javascript" src="{% static 'fluent_comments/js/ajaxcomments.js' %}"></script>
  {% if page.has_audio %}
    <script src="{% static 'cast/js/web-player/embed.4.js' %}"></script>
    {% for pk, audio in page.media_lookup.audio.items %}
      <script>podlovePlayer("#audio_{{ audio.pk }}", "{{ audio.podlove_url }}");</script>
    {% endfor %}
  {% endif %}

{% endblock javascript %}
