Stylisation des liens morts
This commit is contained in:
@@ -13,3 +13,11 @@
|
|||||||
color: var(--color-link-affiliated-hover);
|
color: var(--color-link-affiliated-hover);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dead {
|
||||||
|
color: var(--color-link-dead);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--color-link-dead-hover);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,8 +3,26 @@
|
|||||||
{{- $host := $parsed.Host -}}
|
{{- $host := $parsed.Host -}}
|
||||||
{{- $path := $parsed.Path -}}
|
{{- $path := $parsed.Path -}}
|
||||||
{{- $query := $parsed.RawQuery -}}
|
{{- $query := $parsed.RawQuery -}}
|
||||||
{{- $aff := index site.Data.affiliates.sites $host -}}
|
{{- $page := .Page -}}
|
||||||
|
{{- $site := $page.Site -}}
|
||||||
|
{{- $aff := index $site.Data.affiliates.sites $host -}}
|
||||||
{{- $isAffiliated := false -}}
|
{{- $isAffiliated := false -}}
|
||||||
|
{{- $scratch := $page.Scratch -}}
|
||||||
|
{{- $externalCache := $scratch.Get "externalLinksCache" -}}
|
||||||
|
{{- if not $externalCache -}}
|
||||||
|
{{- $externalCache = dict -}}
|
||||||
|
{{- if fileExists "tools/cache/external_links.yaml" -}}
|
||||||
|
{{- with readFile "tools/cache/external_links.yaml" -}}
|
||||||
|
{{- $parsedCache := transform.Unmarshal . -}}
|
||||||
|
{{- if $parsedCache -}}
|
||||||
|
{{- $externalCache = $parsedCache -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- $scratch.Set "externalLinksCache" $externalCache -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- $cacheEntry := index $externalCache .Destination -}}
|
||||||
|
{{- $isDeadLink := and $cacheEntry (eq (index $cacheEntry "manually_killed") true) -}}
|
||||||
{{- $newURL := .Destination -}}
|
{{- $newURL := .Destination -}}
|
||||||
{{- if and $isExternal $aff -}}
|
{{- if and $isExternal $aff -}}
|
||||||
{{- $param := $aff.param -}}
|
{{- $param := $aff.param -}}
|
||||||
@@ -22,7 +40,18 @@
|
|||||||
{{- else if $isExternal -}}
|
{{- else if $isExternal -}}
|
||||||
{{- $titlePrefix = "Lien externe" -}}
|
{{- $titlePrefix = "Lien externe" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
{{- $classes := slice -}}
|
||||||
|
{{- if $isExternal -}}
|
||||||
|
{{- $classes = $classes | append "external" -}}
|
||||||
|
{{- if $isAffiliated -}}
|
||||||
|
{{- $classes = $classes | append "affiliated" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if $isDeadLink -}}
|
||||||
|
{{- $classes = $classes | append "dead" -}}
|
||||||
|
{{- end -}}
|
||||||
<a href="{{ $newURL }}" title="{{ $titlePrefix }}{{ .Title }}"
|
<a href="{{ $newURL }}" title="{{ $titlePrefix }}{{ .Title }}"
|
||||||
{{- if $isExternal -}} rel="noreferrer" class="external{{ if $isAffiliated }} affiliated{{ end }}" {{- end -}}>
|
{{- if $isExternal -}} rel="noreferrer"{{- end -}}
|
||||||
|
{{- if gt (len $classes) 0 -}} class="{{ delimit $classes " " }}"{{- end -}}>
|
||||||
{{- .Text | safeHTML -}}
|
{{- .Text | safeHTML -}}
|
||||||
</a>
|
</a>
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
--color-link-external-hover: var(--green-300);
|
--color-link-external-hover: var(--green-300);
|
||||||
--color-link-affiliated: var(--pink-500);
|
--color-link-affiliated: var(--pink-500);
|
||||||
--color-link-affiliated-hover: var(--pink-300);
|
--color-link-affiliated-hover: var(--pink-300);
|
||||||
|
--color-link-dead: var(--red-500);
|
||||||
|
--color-link-dead-hover: var(--red-300);
|
||||||
|
|
||||||
/* Border tokens */
|
/* Border tokens */
|
||||||
--border-outer-color: var(--gray-800);
|
--border-outer-color: var(--gray-800);
|
||||||
|
|||||||
Reference in New Issue
Block a user