recettes/layouts/partials/encadre-livre.html
2025-10-06 19:21:06 +02:00

106 lines
No EOL
3.9 KiB
HTML
Executable file

<!-- Pour montrer des infos sur le livre sur la page -->
<style>
.encadre-livre {
width: 300px;
padding: 10px;
border: 1px solid #ccc;
float: right;
margin-left: 20px;
clear: right;
box-sizing: border-box;
overflow: hidden;
}
.encadre-livre .title {
text-align: center;
margin: 0 0 20px 0;
}
.encadre-livre figure img {
margin-left: auto;
margin-right: auto;
}
</style>
{{ $specs := .Page.Params.BookData }}
{{ if $specs }}
<div class="encadre-livre">
<h3 class="title">{{$specs.title}}</h3>
<figure>
{{- if $specs.cover -}}
<!-- First try to get the image as a page resource (for page bundles) -->
{{- $coverResource := .Page.Resources.GetMatch $specs.cover -}}
{{- if not $coverResource -}}
<!-- If not found in page resources, try the global assets directory -->
{{- $coverResource = resources.Get $specs.cover -}}
{{- end -}}
{{- if $coverResource -}}
{{- $thumbCover := $coverResource.Fit "200x200 webp q85" -}}
<img src="{{ $thumbCover.RelPermalink }}" alt="1ère de couverture de {{ $specs.title }} par {{ $specs.author }}">
{{- else -}}
<!-- Cover resource not found anywhere -->
<div class="error">Image non trouvée : {{ $specs.cover }}</div>
{{- end -}}
{{- else -}}
<!-- No cover specified in frontmatter -->
<div class="error">No cover image specified</div>
{{- end -}}
</figure>
<table>
<tbody>
{{ if $specs.publishDate }}
<tr>
<th>Date de publication</th>
<td>{{ $specs.publishDate }}</td>
</tr>
{{ end }}
{{ if $specs.author }}
<tr>
<th>Auteur</th>
<td>{{ $specs.author }}</td>
</tr>
{{ end }}
{{ if $specs.ISBN }}
<tr>
<th>ISBN</th>
<td>{{ $specs.ISBN }}</td>
</tr>
{{ end }}
{{ if $specs.worldCat }}
<tr>
<th colspan="2">
<a href="{{ $specs.worldCat }}">Lien WorldCat</a>
</th>
</tr>
{{ end }}
{{ if $specs.starGrade }}
<tr>
<th>Note perso</th>
<td>
{{ range seq 1 $specs.starGrade }}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 441" width="16px" height="16px">
<path d="M 48 261 L 228 430 L 48 261 L 228 430 Q 240 441 256 441 Q 272 441 284 430 L 464 261 L 464 261 Q 511 217 512 152 L 512 146 L 512 146 Q 511 92 478 54 Q 445 15 393 5 Q 358 0 325 10 Q 293 20 268 45 L 256 57 L 256 57 L 244 45 L 244 45 Q 219 20 187 10 Q 154 0 119 5 Q 67 15 34 54 Q 1 92 0 146 L 0 152 L 0 152 Q 1 217 48 261 L 48 261 Z" />
</svg>
{{ end }}
{{ if ne $specs.starGrade 5 }}
{{ range seq 1 (sub 5 $specs.starGrade) }}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 445" width="16px" height="16px">
<path d="M 226 433 L 223 431 L 226 433 L 223 431 L 48 268 L 48 268 Q 1 223 0 158 L 0 155 L 0 155 Q 1 101 34 61 Q 66 22 119 11 Q 181 0 231 35 Q 245 44 256 57 Q 262 50 270 44 Q 275 39 281 35 Q 281 35 281 35 Q 281 35 281 35 Q 331 0 393 10 Q 446 21 478 61 Q 511 101 512 155 L 512 158 L 512 158 Q 511 223 464 268 L 289 431 L 289 431 L 286 433 L 286 433 Q 273 445 256 445 Q 239 445 226 433 L 226 433 Z M 239 110 Q 239 110 238 109 L 238 109 L 238 109 Q 238 109 238 109 L 220 89 L 220 89 L 220 89 L 220 89 Q 220 89 220 89 Q 202 69 178 61 Q 154 53 128 58 Q 93 65 71 92 Q 49 118 48 155 L 48 158 L 48 158 Q 49 202 81 233 L 256 396 L 256 396 L 431 233 L 431 233 Q 463 202 464 158 L 464 155 L 464 155 Q 463 118 441 92 Q 419 65 384 58 Q 358 53 334 61 Q 310 69 292 89 Q 292 89 292 89 Q 292 89 292 89 L 274 109 L 274 109 Q 274 109 273 110 Q 273 110 273 110 Q 266 117 256 117 Q 246 117 239 110 L 239 110 Z" />
</svg>
{{ end }}
{{ end }}
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ else }}
<div class="notice warning">
<p>Pas d'informations trouvées :(</p>
</div>
{{ end }}