refactor: Ajout de partials

This commit is contained in:
Simon 2021-04-05 17:54:05 +02:00
parent c878f601db
commit 2357361376
5 changed files with 50 additions and 83 deletions

View File

@ -1,31 +1,12 @@
{{ define "main" }} {{ define "main" }}
<div class="info"> <div class="info">
<a href="/"> <a href="/">
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
</a> </a>
{{ .Content }} {{ .Content }}
</div> </div>
<div class="portfolio"> <div class="portfolio">
<ul class="categories"> {{ partial "categories" . }}
{{- range $name, $items := .Site.Taxonomies.categories }} {{ partial "projects" . }}
<li><a href="{{ "categories/" | relLangURL }}{{ $name | urlize | lower }}/#categories">#{{ $name | title | humanize }}</a></li> </div>
{{- end }}
</ul>
<ul class="projets">
{{ $pages := (.Site.GetPage "/portfolio").Pages.Reverse }}
{{ range $pages }}
<li class="item">
{{ $image := .Resources.GetMatch (default "*" .Params.image) }}
{{ if $image }}
{{ $resized := $image.Fill "280x280 Center"}}
<img src="{{ $resized.RelPermalink }}">
{{ end }}
<a href="{{.RelPermalink}}" class="description">
<h2>{{ .Title }}</h2>
<p>{{ .Description }}</p>
</a>
</li>
{{ end }}
</ul>
</div>
{{ end }} {{ end }}

View File

@ -1,31 +1,11 @@
{{ define "main" }} {{ define "main" }}
<div class="info"> <div class="info">
<a href="/">Accueil</a> <a href="/">Accueil</a>
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
{{ .Content }} {{ .Content }}
</div> </div>
<div class="portfolio"> <div class="portfolio">
<ul class="categories"> {{ partial "categories" . }}
{{- range $name, $items := .Site.Taxonomies.categories }} {{ partial "projects" . }}
<li><a href="{{ "categories/" | relLangURL }}{{ $name | urlize | lower }}/#categories">#{{ $name | title | humanize }}</a></li> </div>
{{- end }}
</ul>
<ul class="projets">
{{ $pages := (.Site.GetPage "/portfolio").Pages.Reverse }}
{{ range $pages }}
<li class="item">
{{ $image := .Resources.GetMatch (default "*" .Params.image) }}
{{ if $image }}
{{ $resized := $image.Fill "280x280 Center"}}
<img src="{{ $resized.RelPermalink }}">
{{ end }}
<a href="{{.RelPermalink}}" class="description">
<h2>{{ .Title }}</h2>
<p>{{ .Description }}</p>
</a>
</li>
{{ end }}
</ul>
</div>
{{ end }} {{ end }}

View File

@ -0,0 +1,10 @@
<ul class="categories" id="categories">
{{ $term := .Data.Term }}
{{- range $name, $items := .Site.Taxonomies.categories }}
<li>
<a {{if eq ($name | title) $term }}class="actif" {{ end }}href="{{ "categories/" | relLangURL }}{{ $name | urlize | lower }}/#categories">
#{{ $name | title | humanize }}
</a>
</li>
{{- end }}
</ul>

View File

@ -0,0 +1,20 @@
<ul class="projets" id="projets">
{{
$pages := cond (or .IsHome .IsPage)
(.Site.GetPage "/portfolio").Pages.Reverse
.Data.Pages.Reverse
}}
{{ range $pages }}
<li class="item">
{{ $image := .Resources.GetMatch (default "*" .Params.image) }}
{{ if $image }}
{{ $resized := $image.Fill "280x280 Center"}}
<img src="{{ $resized.RelPermalink }}">
{{ end }}
<a href="{{.RelPermalink}}" class="description">
<h2>{{ .Title }}</h2>
<p>{{ .Description }}</p>
</a>
</li>
{{ end }}
</ul>

View File

@ -8,31 +8,7 @@
{{ end }} {{ end }}
</div> </div>
<div class="portfolio"> <div class="portfolio">
<ul class="categories" id="categories"> {{ partial "categories" . }}
{{ $term := .Data.Term }} {{ partial "projects" . }}
{{- range $name, $items := .Site.Taxonomies.categories }}
<li>
<a {{if eq ($name | title) $term }}class="actif" {{ end }}href="{{ "categories/" | relLangURL }}{{ $name | urlize | lower }}/#categories">
#{{ $name | title | humanize }}
</a>
</li>
{{- end }}
</ul>
<ul class="projets" id="projets">
{{ $pages := .Data.Pages.Reverse }}
{{ range $pages }}
<li class="item">
{{ $image := .Resources.GetMatch (default "*" .Params.image) }}
{{ if $image }}
{{ $resized := $image.Fill "280x280 Center"}}
<img src="{{ $resized.RelPermalink }}">
{{ end }}
<a href="{{.RelPermalink}}" class="description">
<h2>{{ .Title }}</h2>
<p>{{ .Description }}</p>
</a>
</li>
{{ end }}
</ul>
</div> </div>
{{ end }} {{ end }}