{% extends 'layout.html.twig' %}
{% block body %}
{% if author.image is defined %}
{% endif %}
{% if author.nip05 is defined %}
{% if author.nip05 is iterable %}
{% for nip05Value in author.nip05 %}
{% endfor %}
{% else %}
{% endif %}
{% endif %}
{% if author.about is defined %}
{{ author.about|markdown_to_html|mentionify|linkify }}
{% endif %}
{# Extract title #}
{% set title = null %}
{% for tag in event.tags %}
{% if tag[0] == 'title' %}
{% set title = tag[1] %}
{% endif %}
{% endfor %}
{# Extract first image from imeta tags #}
{% set firstImageUrl = null %}
{% set firstVideoUrl = null %}
{% set imageAlt = null %}
{% set isVideo = false %}
{% for tag in event.tags %}
{% if tag[0] == 'imeta' %}
{% set videoUrl = null %}
{% set imageUrl = null %}
{% for i in 1..(tag|length - 1) %}
{% set param = tag[i] %}
{% if param starts with 'url ' %}
{% set potentialUrl = param[4:] %}
{# Check if it's a video URL #}
{% if potentialUrl matches '/\\.(mp4|webm|ogg|mov)$/i' or potentialUrl matches '/video/i' %}
{% set videoUrl = potentialUrl %}
{% set isVideo = true %}
{% else %}
{% set imageUrl = potentialUrl %}
{% endif %}
{% elseif param starts with 'image ' %}
{# Preview image for video #}
{% set imageUrl = param[6:] %}
{% elseif param starts with 'alt ' %}
{% set imageAlt = param[4:] %}
{% endif %}
{% endfor %}
{# Set the first video and image found #}
{% if videoUrl and firstVideoUrl is null %}
{% set firstVideoUrl = videoUrl %}
{% endif %}
{% if imageUrl and firstImageUrl is null %}
{% set firstImageUrl = imageUrl %}
{% endif %}
{% endif %}
{% endfor %}
{# Generate nevent for linking #}
{% set eventId = event.id %}
{% set noteId = event.noteId %}
{% if firstImageUrl %}