feat(gallery): add historical date parsing

feat: add logo file
This commit is contained in:
Matthieu Bessat 2022-09-29 17:24:11 +02:00
parent b5785c8218
commit bb43b2bc9d
9 changed files with 124 additions and 18 deletions

4
assets/sass/footer.scss Normal file
View file

@ -0,0 +1,4 @@
footer {
margin-top: 1rem;
background-color: blue;
}

View file

@ -17,7 +17,7 @@
.gallery__items {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
grid-template-columns: repeat(4, minmax(13rem, 1fr));
grid-gap: 1rem;
}
@ -41,8 +41,24 @@
justify-content: space-between;
}
@media (max-width: $lg-breakpoint) {
// .gallery__items {
// grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr))
// }
}
@media (max-width: $md-breakpoint) {
.gallery {
display: block;
}
.gallery__items {
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
}
}
@media (max-width: $xs-breakpoint) {
.gallery__items {
grid-template-columns: 1fr;
}
}

View file

@ -1,4 +1,4 @@
$lg-breakpoint: 1500px;
$lg-breakpoint: 1600px;
$md-breakpoint: 1100px;
$sm-breakpoint: 900px;
$xs-breakpoint: 400px;
@ -17,4 +17,5 @@ $secondary: red;
@import 'header.scss';
@import 'gallery.scss';
@import 'single_image.scss';
@import 'footer.scss';

View file

@ -26,6 +26,8 @@
.single-image__property {
display: flex;
align-items: center;
margin-bottom: .2rem;
min-height: 2rem;
div:first-of-type {
margin-right: 1rem;
}
@ -41,6 +43,7 @@
margin: 0;
list-style-type: none;
display: flex;
align-items: center;
padding: 0;
li {
border: 1px solid black;
@ -68,3 +71,18 @@
}
}
@media (max-width: $sm-breakpoint) {
.single-image {
.single-image__property {
display: block;
}
}
}

View file

@ -5,5 +5,6 @@ mime_type: image/jpeg
imtags:
- crypte
- etoile
#inception: 2000-10-08
---

View file

@ -6,20 +6,48 @@
<h1>{{ .Title }}</h1>
<div class="single-image__property single-image__tags">
<div class="property-name">Étiquettes associées à l'image :</div>
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-tags" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M7.859 6h-2.834a2.025 2.025 0 0 0 -2.025 2.025v2.834c0 .537 .213 1.052 .593 1.432l6.116 6.116a2.025 2.025 0 0 0 2.864 0l2.834 -2.834a2.025 2.025 0 0 0 0 -2.864l-6.117 -6.116a2.025 2.025 0 0 0 -1.431 -.593z" />
<path d="M17.573 18.407l2.834 -2.834a2.025 2.025 0 0 0 0 -2.864l-7.117 -7.116" />
<path d="M6 9h-.01" />
</svg>
<ul>
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-tags" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M7.859 6h-2.834a2.025 2.025 0 0 0 -2.025 2.025v2.834c0 .537 .213 1.052 .593 1.432l6.116 6.116a2.025 2.025 0 0 0 2.864 0l2.834 -2.834a2.025 2.025 0 0 0 0 -2.864l-6.117 -6.116a2.025 2.025 0 0 0 -1.431 -.593z" />
<path d="M17.573 18.407l2.834 -2.834a2.025 2.025 0 0 0 0 -2.864l-7.117 -7.116" />
<path d="M6 9h-.01" />
</svg>
{{ range .Params.imtags }}
<li><a href="/tag_images/{{ . | urlize }}">{{ . }}</a></li>
<li><a href="/imtags/{{ . | urlize }}">{{ . }}</a></li>
{{ end }}
</ul>
</div>
<div class="single-image__property single-image__original-name">
<div class="property-name">Nom original :</div><pre>{{ .Params.original_name }}</pre>
<div class="property-name">Nom original :</div>
<pre>{{ .Params.original_name }}</pre>
</div>
<div class="single-image__property single-image__date">
{{ with .Params.inception }}
{{/*
{{ $dateType := "exact" }}
{{ $date := "" }}
{{ $dateFrom := "" }}
{{ $dateTo := "" }}
{{ $datePrecision := "" }}
{{ if reflect.IsMap . }}
{{ $dateType = "range" }}
{{ $dateFrom = .from }}
{{ $dateTo = .to }}
{{ else }}
{{ $date = . }}
{{ end }}
{{ if eq $dateType "range" }}
Document daté entre le {{ .from }} et {{ .to }}
{{ else }}
{{ partial "FormatHistoricalDate.html" . }}
{{ end }}
*/}}
Date du document : {{ partial "FormatHistoricalDate.html" . }}
{{ else }}
Pas encore de de date ajouté
{{ end }}
</div>
<div class="single-image__content">
{{ .Content }}

View file

@ -0,0 +1,36 @@
{{ $formattedDate := "" }}
{{ $rawDate := . }}
{{- $date := "1800-01-01" -}}
{{- $datePrecision := "day" -}}
{{ if reflect.IsMap $rawDate }}
{{ partial "FormatHistoricalDate" ($rawDate.from) }}
-
{{ partial "FormatHistoricalDate" ($rawDate.to) }}
{{ else }}
{{ $rawDate = string $rawDate }}
{{ if eq (len $rawDate) 4 }}
{{ $datePrecision = "year" }}
{{ $date = printf "%s-01-01" $rawDate }}
{{ end }}
{{ if eq (len $rawDate) 7 }}
{{ $datePrecision = "month" }}
{{ $date = printf "%s-01" $rawDate }}
{{ end }}
{{ if eq (len $rawDate) 10 }}
{{ $datePrecision = "day" }}
{{ $date = $rawDate }}
{{ end }}
{{- if eq $datePrecision "year" -}}
{{ $formattedDate = ($date | time.Format "2006") }}
{{- end -}}
{{- if eq $datePrecision "month" -}}
{{ $formattedDate = ($date | time.Format "January 2006") }}
{{- end -}}
{{- if eq $datePrecision "day" -}}
{{ $formattedDate = ($date | time.Format "2 January 2006") }}
{{- end -}}
{{ end }}
{{ printf "%s" $formattedDate }}

View file

@ -12,29 +12,30 @@
<div class="gallery-tags__title">Filtrer par étiquettes</div>
<div class="gallery-tags__list">
<ul>
{{- if eq (.Scratch.Get "image_list_context") "imtags" -}}
{{- if eq (.Scratch.Get "image_list_context") "imtags" -}}
<li>
<a href="/images">Tout</a>
</li>
{{- end -}}
{{- range .Site.Taxonomies.imtags -}}
<a href="/images">Tout</a>
</li>
{{- end -}}
{{- range .Site.Taxonomies.imtags -}}
<li>
<a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a>
</li>
{{- end -}}
{{- end -}}
</ul>
</div>
</div>
<div class="gallery__items-container">
<div class="gallery__items">
{{ range (.Paginator 8).Pages }}
{{ range $item := (.Paginator 8).Pages }}
<a class="gallery__item" href="{{ .RelPermalink }}">
{{ $image := .Resources.GetMatch "original.jpg" }}
{{ $image := $image.Resize "x350" }}
{{ with $image }}
<img
class="gallery__image"
title="{{ $item.Title }}"
src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}"
/>
{{ end }}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.4 KiB