{# Card de résultat à partir d'un ProviderBookResult (DTO BookSearchService). À la différence de _hit_card.html.twig (qui rend un SearchHit Meili pour un Work déjà matérialisé), ce partial rend un livre découvert via Google Books ou Open Library. Le clic passe par /livres/lookup qui matérialise à la volée le Work + Edition en BDD, puis redirige vers la fiche canonique. Préfixe le hit par un eyebrow discret rappelant la source (GB / OL) pour nous, debug. À retirer ou rendre conditionnel si jugé bruyant en UX. #} {# Hit déjà rattaché à un Work matérialisé (source 'bdd', ou hit GB/OL patché) : lien DIRECT vers la fiche, plus rapide et sans 404 sur les hits 'bdd' qui n'ont pas d'externalId provider. Sinon : lookup→matérialisation à la volée. #} {% if hit.workPublicId %} {% set href = path('app_work_show', { publicId: hit.workPublicId }) %} {% else %} {% set href = path('app_work_lookup', { source: hit.source, id: hit.source == 'openlibrary' ? hit.openLibraryId : hit.googleBooksId }) %} {% endif %} {% set fallback_url = path('covers_resolve', { title: hit.title, author: hit.authors[0]|default('') }) %}
  • {# Cover : GB direct si dispo, sinon endpoint lazy `/covers/resolve` (302 → image OL ou 404 → onerror swap placeholder). Le Stimulus controller `book-enrich` peut aussi patcher la cover via JSON. #} Couverture de {{ hit.title }}
    {# Découpe titre/méta. Gère le cas des séries FR où GB met « série T{N} » en titre et le VRAI titre du tome dans le subtitle (cf. BookTitleExtension). Sinon : split éditorial ":" / " - " ("Naruto: Chapter Book, Vol. 1", "Houris - Prix Goncourt 2024"). #} {% set tparts = book_title_parts(hit.title, hit.subtitle|default('')) %}

    {{ tparts.main }}

    {% if tparts.meta %}
    {{ tparts.meta }}
    {% endif %}
    {% if hit.authors|length > 0 %}{{ hit.authors|join(', ') }}{% else %}Auteur inconnu{% endif %} {% if hit.publishedYear %} · {{ hit.publishedYear }}{% endif %}