refactor: Simplify url generation

This commit is contained in:
Simon 2024-03-13 09:51:55 +01:00
parent 72409f0c5a
commit 762fd00da2
2 changed files with 26 additions and 14 deletions

View File

@ -34,13 +34,20 @@
<p>{{ $service.description | default $defaultValues.description }}</p> <p>{{ $service.description | default $defaultValues.description }}</p>
<div class="btn-group" role="group" aria-label="Basic outlined example"> <div class="btn-group" role="group" aria-label="Basic outlined example">
<a href="{{ $service.doc | default $defaultValues.doc }}" class="btn btn-outline-primary">Guide</a> <a href="{{ $service.doc | default $defaultValues.doc }}" class="btn btn-outline-primary">Guide</a>
{{ $url := "" }}
{{ if $service.subdomain }} {{ if $service.subdomain }}
<a href="https://{{ print $service.subdomain "." site.Params.domain }}/" class="btn btn-primary">Accéder au service</a> {{ $url = print "https://" $service.subdomain "." site.Params.domain "/" }}
{{ else if $service.link }} {{ else if $service.link }}
<a href="{{ $service.link }}/" class="btn btn-primary">Accéder au service</a> {{ $url = print $service.link "/" }}
{{ else }} {{ else }}
<a href="https://{{ print $defaultValues.subdomain "." site.Params.domain }}/" class="btn btn-primary">Accéder au service</a> {{ $url = print "https://" $defaultValues.subdomain "." site.Params.domain "/" }}
{{ end }} {{ end }}
<a
href="{{ $url }}"
class="btn btn-primary"
>
Accéder au service
</a>
</div> </div>
{{ if site.Params.poweredBy }} {{ if site.Params.poweredBy }}
<p class="text-muted"><small>Propulsé par <a href="{{ $defaultValues.tool.link }}">{{ $defaultValues.tool.name }}</a></small></p> <p class="text-muted"><small>Propulsé par <a href="{{ $defaultValues.tool.link }}">{{ $defaultValues.tool.name }}</a></small></p>

View File

@ -1,19 +1,24 @@
<hr class="mt-1 mb-1"/>
<ul id="socialMenu" class="nav mx-auto flex-row order-lg-4"> <ul id="socialMenu" class="nav mx-auto flex-row order-lg-4">
{{ range $service := site.Data.services }} {{- range $service := site.Data.services -}}
{{ $defaultValues := index site.Data.portails.services $service.name }} {{- $defaultValues := index site.Data.portails.services $service.name -}}
{{ $icon := $service.icon | default $defaultValues.icon }} {{- $icon := $service.icon | default $defaultValues.icon -}}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link social-link" title="{{ $service.title | default $defaultValues.title }}" href="{{- if $service.subdomain -}} {{- $url := "" -}}
{{- print "https://" $service.subdomain "." site.Params.domain -}} {{- if $service.subdomain -}}
{{- $url = print "https://" $service.subdomain "." site.Params.domain "/" -}}
{{- else if $service.link -}} {{- else if $service.link -}}
{{- $service.link -}} {{- $url = print $service.link "/" -}}
{{- else -}} {{- else -}}
{{- print "https://" $defaultValues.subdomain "." site.Params.domain -}} {{- $url = print "https://" $defaultValues.subdomain "." site.Params.domain "/" -}}
{{- end -}}"> {{- end -}}
{{- partial "inline-svg" $icon }}&nbsp; <a
class="nav-link social-link"
title="{{ $service.title | default $defaultValues.title }}"
href="{{ $url }}"
>
{{- partial "inline-svg" $icon -}}
<small class="ms-2 visually-hidden">{{ $service.title | default $defaultValues.title }}</small> <small class="ms-2 visually-hidden">{{ $service.title | default $defaultValues.title }}</small>
</a> </a>
</li> </li>
{{ end -}} {{- end -}}
</ul> </ul>