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

108 lines
No EOL
2.7 KiB
HTML
Executable file

<!-- Pour montrer des infos sur la machine sur la page -->
<style>
.encadre-maec {
width: 300px;
padding: 10px;
border: 1px solid #ccc;
float: right;
margin-left: 20px;
clear: right;
box-sizing: border-box;
overflow: hidden;
}
.encadre-maec .title {
text-align: center;
margin: 0 0 20px 0;
}
.encadre-maec figure img {
margin-left: auto;
margin-right: auto;
}
</style>
{{ $specs := .Page.Params.machineSpecs }}
{{ if $specs }}
<div class="encadre-maec">
<h3 class="title">{{$specs.make}} {{$specs.model}}</h3>
<figure>
{{- if $specs.image -}}
<!-- First try to get the image as a page resource (for page bundles) -->
{{- $imageResource := .Page.Resources.GetMatch $specs.image -}}
{{- if not $imageResource -}}
<!-- If not found in page resources, try the global assets directory -->
{{- $imageResource = resources.Get $specs.image -}}
{{- end -}}
{{- if $imageResource -}}
{{- $thumbimage := $imageResource.Fit "200x200 webp q85" -}}
<img src="{{ $thumbimage.RelPermalink }}" alt="1ère de couverture de {{ $specs.title }} par {{ $specs.author }}">
{{- else -}}
<!-- image resource not found anywhere -->
<div class="error">Image non trouvée : {{ $specs.image }}</div>
{{- end -}}
{{- else -}}
<!-- No image specified in frontmatter -->
<div class="error">No image image specified</div>
{{- end -}}
</figure>
<table>
<tbody>
{{ if $specs.make }}
<tr>
<th>Marque</th>
<td>{{ $specs.make }}</td>
</tr>
{{ end }}
{{ if $specs.model }}
<tr>
<th>Modèle</th>
<td>{{ $specs.model }}</td>
</tr>
{{ end }}
{{ if $specs.type }}
<tr>
<th>Type</th>
<td>{{ $specs.type }}</td>
</tr>
{{ end }}
{{ if $specs.dateManufactured }}
<tr>
<th>Date de fabrication</th>
<td>{{ $specs.dateManufactured }}</td>
</tr>
{{ end }}
{{ if $specs.massKg }}
<tr>
<th>Masse</th>
<td>{{ $specs.massKg }} kg</td>
</tr>
{{ end }}
{{ if $specs.widthCm }}
<tr>
<th>Largeur</th>
<td>{{ $specs.widthCm }} cm</td>
</tr>
{{ end }}
{{ if $specs.serialNumber }}
<tr>
<th>N° de série</th>
<td>{{ $specs.serialNumber }}</td>
</tr>
{{ end }}
{{ if $specs.linkTpdb }}
<tr>
<th colspan="2">
<a href="{{ $specs.linkTpdb }}">Typewriter Database</a>
</th>
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ else }}
<div class="notice warning">
<p>Pas d'informations trouvées :(</p>
</div>
{{ end }}