mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
feat(link): add external link guard feature support (#729)
* feat(external-link-guard): add native redirect mode and improve external-link guard UX * fix(external-link-guard): remove redirect_url and clarify scope/new_tab_policy docs * i18n(external-link-guard): localize guard texts across non-English locales * feat(config)!: migrate `site.Params.externalIcon` to `site.Params.link.external_icon` * refactor: implement regular and card link rendering * feat(link-guard): implement link redirection page with copy and confirm functionality * revert * feat: implement link guard dialog for external links --------- Co-authored-by: Cell <1024@lruihao.cn>
This commit is contained in:
@@ -1,88 +1,157 @@
|
||||
{{- $rel := "" -}}
|
||||
{{- $external := false -}}
|
||||
{{- /*
|
||||
Link rendering partial for regular and card-style links.
|
||||
- Auto-detects external links and applies target/rel policies.
|
||||
- Supports optional icon, download hint, and external icon display.
|
||||
- Supports card mode with URL meta and favicon fallback.
|
||||
@param {String} .Destination target URL
|
||||
@param {String} [.Content] link label HTML
|
||||
@param {String} [.Title] title attribute
|
||||
@param {String} [.Class] custom CSS classes
|
||||
@param {Boolean} [.Newtab] force external behavior
|
||||
@param {Boolean} [.Noreferrer] whether to include noreferrer (default: true)
|
||||
@param {Boolean} [.ExternalIcon] whether to show external-link icon
|
||||
@param {Object} [.Icon] icon params for plugin/icon.html
|
||||
@param {Boolean} [.Card] whether to render card link layout
|
||||
@param {String} [.CardIcon] card icon URL or icon class
|
||||
@param {String} [.Download] download attribute value
|
||||
*/ -}}
|
||||
|
||||
{{- /* Regular link rendering */ -}}
|
||||
{{- define "render-link-regular" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $config := .config -}}
|
||||
{{- $isExternal := .isExternal -}}
|
||||
{{- $externalIcon := $ctx.ExternalIcon | default $config.externalIcon -}}
|
||||
{{- with $ctx.Icon -}}
|
||||
{{- partial "plugin/icon.html" . }}
|
||||
{{ end -}}
|
||||
{{- with $ctx.Content -}}
|
||||
{{- . | safeHTML -}}
|
||||
{{- end -}}
|
||||
{{- if
|
||||
$externalIcon
|
||||
| and $isExternal
|
||||
| and (not (hasPrefix $ctx.Content `<img`))
|
||||
| and (not (strings.HasSuffix $ctx.Content `</i>`))
|
||||
| and (not (strings.HasSuffix $ctx.Content `):`))
|
||||
-}}
|
||||
{{- if $ctx.Download -}}
|
||||
{{- dict "Class" "fa-solid fa-cloud-download-alt ms-1 text-secondary" | partial "plugin/icon.html" -}}
|
||||
{{- else -}}
|
||||
{{- dict "Class" "fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" | partial "plugin/icon.html" -}}
|
||||
{{- end -}}
|
||||
{{- else if $ctx.Download }}
|
||||
{{- dict "Class" "fa-solid fa-download ms-1 text-secondary" | partial "plugin/icon.html" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Card link rendering */ -}}
|
||||
{{- define "render-link-card" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $url := .url -}}
|
||||
{{- $cardIcon := $ctx.CardIcon -}}
|
||||
{{- if (not $cardIcon) | and $url.Host -}}
|
||||
{{- with partial "function/get-remote-image.html" (dict "Src" (add "https://favicon.im/" $url.Host)) -}}
|
||||
{{- $cardIcon = .RelPermalink -}}
|
||||
{{- else with partial "function/get-remote-image.html" (dict "Src" (add "https://api.lruihao.cn/google/s2/favicons?sz=64&domain=" $url.Host)) -}}
|
||||
{{- $cardIcon = .RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
<span class="cl-backdrop"></span>
|
||||
<span class="cl-content">
|
||||
<span class="cl-text">
|
||||
<span class="cl-title">
|
||||
{{- with $ctx.Icon -}}
|
||||
{{- partial "plugin/icon.html" . }}
|
||||
{{ end -}}
|
||||
{{- with $ctx.Content -}}
|
||||
{{- . | safeHTML -}}
|
||||
{{- end -}}
|
||||
</span>
|
||||
<span class="cl-meta">
|
||||
<svg class="cl-icon-link" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M574 665.4c-3.1-3.1-8.2-3.1-11.3 0L446.5 781.6c-53.8 53.8-144.6 59.5-204 0-59.5-59.5-53.8-150.2 0-204l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3l-39.8-39.8c-3.1-3.1-8.2-3.1-11.3 0L191.4 526.5c-84.6 84.6-84.6 221.5 0 306s221.5 84.6 306 0l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3L574 665.4zM832.6 191.4c-84.6-84.6-221.5-84.6-306 0L410.3 307.6c-3.1 3.1-3.1 8.2 0 11.3l39.7 39.7c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c53.8-53.8 144.6-59.5 204 0 59.5 59.5 53.8 150.2 0 204L665.3 562.6c-3.1 3.1-3.1 8.2 0 11.3l39.8 39.8c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c84.5-84.6 84.5-221.5 0-306.1z" fill="#a9a9b3"></path><path d="M610.1 372.3c-3.1-3.1-8.2-3.1-11.3 0L372.3 598.7c-3.1 3.1-3.1 8.2 0 11.3l39.6 39.6c3.1 3.1 8.2 3.1 11.3 0l226.4-226.4c3.1-3.1 3.1-8.2 0-11.3l-39.5-39.6z" fill="#a9a9b3"></path></svg>
|
||||
<span class="cl-url">
|
||||
{{- $url.String | safeURL | strings.TrimPrefix (add $url.Scheme "://") -}}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
{{- if $ctx.Download -}}
|
||||
<svg class="cl-shortcut-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="64" height="64"><path d="M824.32 473.6c-15.36-2.56-25.6-15.36-25.6-30.72 0-112.64-71.68-217.6-179.2-250.88-148.48-46.08-289.28 38.4-332.8 166.4-2.56 10.24-12.8 17.92-23.04 20.48C143.36 401.92 51.2 509.44 51.2 637.44v2.56c0 115.2 97.28 204.8 209.92 204.8h524.8c102.4-2.56 184.32-84.48 184.32-186.88 2.56-89.6-61.44-163.84-145.92-184.32z m-273.92 225.28c-12.8 12.8-30.72 15.36-46.08 10.24H501.76c-5.12-2.56-10.24-5.12-15.36-10.24L366.08 578.56c-15.36-15.36-15.36-43.52 0-58.88 15.36-15.36 43.52-15.36 58.88 0l51.2 51.2V352.4608c0-23.04 17.92-40.96 40.96-40.96 23.04 0 40.96 17.92 40.96 40.96v218.4192l51.2-51.2c17.92-17.92 43.52-17.92 61.44 0 17.92 15.36 17.92 40.96 0 58.88l-120.32 120.32z" fill="#4FC089"></path></svg>
|
||||
{{- else -}}
|
||||
{{- with $cardIcon -}}
|
||||
{{- if (strings.HasPrefix . "fa") -}}
|
||||
<i class="{{ . }} cl-shortcut-icon"></i>
|
||||
{{- else -}}
|
||||
<img src="{{ . }}" alt="card image" class="cl-shortcut-image">
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
<svg class="cl-shortcut-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="64" height="64"><path d="M960 512c0 249.408-203.2 448-448 448-244.778667 0-448-198.592-448-448S262.592 64 512 64s448 198.592 448 448" fill="#2196F3"></path><path d="M507.52 718.08c0-8.96-4.48-13.44-13.44-17.92-26.88-8.96-53.76-8.96-76.16-31.381333-4.48-8.96-4.48-17.92-8.96-26.88-8.96-8.96-31.36-13.44-44.8-17.92h-89.6c-13.44-4.48-22.4-22.4-31.36-35.84 0-4.48 0-13.461333-8.96-13.461334-8.96-4.458667-17.92 4.501333-26.88 0-4.48-4.458667-4.48-8.96-4.48-13.418666 0-13.461333 8.96-26.901333 17.92-35.861334 13.44-8.96 26.88 4.48 40.32 4.48 4.48 0 4.48 0 8.96 4.48 13.44 4.48 17.92 22.4 17.92 35.861334v8.96c0 4.48 4.48 4.48 8.96 4.48 4.48-22.4 4.48-44.821333 8.96-67.2 0-26.88 26.88-53.781333 49.28-62.72 8.96-4.458667 13.44 4.501333 22.4 0 26.88-8.96 94.08-35.84 80.64-71.658667-8.96-31.381333-35.84-62.698667-71.68-58.24-8.96 4.501333-13.44 8.96-22.4 13.461333-13.44 8.96-40.32 35.84-53.76 35.84-22.4-4.48-22.4-35.84-17.92-49.301333 4.48-17.92 44.8-76.138667 71.68-67.178667l17.92 17.92c8.96 4.48 22.4 4.48 35.84 4.48 4.48 0 8.96 0 13.44-4.48 4.48-4.48 4.48-4.48 4.48-8.96 0-13.44-13.44-26.901333-22.4-35.861333s-22.4-17.92-35.84-22.378667c-44.8-13.461333-116.48 4.458667-152.32 35.84-35.84 31.36-62.72 85.12-80.64 129.92-8.96 26.88-17.92 62.698667-22.4 94.08-4.48 22.4-8.96 40.32 4.48 62.698667 13.44 26.88 40.32 53.781333 67.2 71.68 17.92 13.44 53.76 13.44 71.68 35.84 13.44 17.941333 8.96 40.32 8.96 62.72 0 26.88 17.92 49.28 26.88 71.658667 4.48 13.461333 8.96 31.381333 13.44 44.821333 0 4.48 4.48 31.36 4.48 35.84 26.88 13.44 49.28 26.901333 80.64 35.861333 4.48 0 22.4-26.901333 22.4-31.381333 13.44-13.44 22.4-31.36 35.84-40.32 8.96-4.48 17.92-8.96 26.88-17.941333 8.96-8.96 13.44-26.88 17.92-40.32 4.48-8.938667 8.96-26.858667 4.48-40.298667M516.48 305.92c4.48 0 8.96-4.48 17.92-8.96 13.44-8.96 26.901333-22.4 40.32-31.36 13.461333-8.96 26.901333-22.4 35.861333-31.36 13.44-8.96 22.4-26.88 26.88-40.341333 4.48-8.96 17.941333-26.88 13.44-40.32-4.48-8.96-26.88-13.44-35.84-17.92C579.2 126.698667 547.84 122.24 512 122.24c-13.44 0-31.36 4.458667-35.84 17.92-4.48 22.4 13.44 17.92 31.36 22.4 0 0 4.48 35.84 4.48 40.32 4.48 22.421333-8.96 35.84-8.96 58.24 0 13.44 0 35.84 8.96 44.8h4.48zM892.8 619.52c4.501333-8.96 4.501333-22.4 8.96-31.36 4.501333-22.421333 4.501333-44.8 4.501333-67.2 0-44.8-4.501333-89.578667-17.92-129.92-8.96-13.44-13.461333-26.88-17.941333-40.341333-8.96-22.378667-22.4-44.8-40.32-62.698667-17.92-22.4-40.341333-85.12-80.64-67.2-13.44 4.501333-22.4 22.421333-31.36 31.381333l-26.88 40.32c-4.501333 4.48-8.96 13.44-4.501333 17.92 0 4.48 4.501333 4.48 8.96 4.48 8.96 4.501333 13.461333 4.501333 22.421333 8.96 4.48 0 8.96 4.501333 4.48 8.96 0 0 0 4.501333-4.48 4.501334-22.421333 22.4-44.8 40.32-67.2 62.698666-4.48 4.48-8.96 13.44-8.96 17.92s4.48 4.48 4.48 8.96c0 4.501333-4.48 4.501333-8.96 8.96-8.96 4.501333-17.92 8.96-22.4 13.461334-4.48 8.96 0 22.4-4.48 31.36-4.48 22.4-17.941333 40.32-26.901333 62.72-8.96 13.418667-13.418667 26.88-22.378667 40.32 0 17.92-4.501333 31.36 4.458667 44.8 22.421333 31.36 62.72 13.44 94.08 26.901333 8.96 4.458667 17.92 4.458667 22.421333 13.418667 13.418667 13.461333 13.418667 35.861333 17.92 49.301333 4.458667 17.92 8.96 35.84 17.92 53.76 4.48 22.421333 13.44 44.821333 17.92 62.72 40.341333-31.36 76.16-67.178667 103.04-112 26.88-31.424 40.341333-67.242667 53.76-103.104" fill="#CDDC39"></path></svg>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</span>
|
||||
{{- end -}}
|
||||
|
||||
{{- $blockSchemes := slice "javascript" "mailto" "tel" "file" "data" "vscode" "trae" -}}
|
||||
{{- $config := partial "function/snake2camel.html" site.Params.link -}}
|
||||
{{- $rel := .Rel | default "" -}}
|
||||
{{- $isExternal := false -}}
|
||||
{{- $noreferrer := true -}}
|
||||
{{- if eq .Noreferrer false -}}
|
||||
{{- $noreferrer = false -}}
|
||||
{{- end -}}
|
||||
{{- $url := urls.Parse .Destination -}}
|
||||
{{- if $url.IsAbs | or .Newtab -}}
|
||||
{{- $rel = cond $noreferrer "external nofollow noopener noreferrer" "external nofollow" -}}
|
||||
{{- $external = true -}}
|
||||
{{/* {{ partial "_debug/dump" $url }} */}}
|
||||
{{- if $url.IsAbs | and (not (in $blockSchemes $url.Scheme)) -}}
|
||||
{{- $isExternal = not (strings.HasPrefix .Destination site.BaseURL) -}}
|
||||
{{- end -}}
|
||||
{{- if $isExternal -}}
|
||||
{{- $rel = add $rel " external nofollow" -}}
|
||||
{{- if $noreferrer -}}
|
||||
{{- $rel = add $rel " noopener noreferrer" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $class := .Class | default "" -}}
|
||||
{{- if eq .Card true -}}
|
||||
{{- $class = trim (printf "%v %v" "card-link" $class) " " -}}
|
||||
{{- end -}}
|
||||
<a href="{{ .Destination | safeURL }}"
|
||||
{{- with .Title }} title="{{ . }}"{{- end -}}
|
||||
{{- if $external }} target="_blank"{{- end -}}
|
||||
{{- if $rel | or .Rel }} rel="{{ $rel }}{{ with .Rel }} {{ . }}{{ end }}"{{- end -}}
|
||||
{{- with $class }} class="{{ with $class }}{{ . }}{{ end }}"{{- end -}}
|
||||
{{- with .Download }} download="{{ . }}"{{- end -}}
|
||||
>
|
||||
{{- if ne .Card true -}}
|
||||
{{- with .Icon -}}
|
||||
{{- partial "plugin/icon.html" . }}
|
||||
{{ end -}}
|
||||
{{- with .Content -}}
|
||||
{{- . | safeHTML -}}
|
||||
{{- end -}}
|
||||
{{- if
|
||||
(.ExternalIcon | default false)
|
||||
| and $external | and (eq (hasPrefix .Content `<img`) false)
|
||||
| and (eq ((strings.HasSuffix .Content `</i>`) | or (strings.HasSuffix .Content `):`)) false)
|
||||
-}}
|
||||
{{- if .Download -}}
|
||||
{{- dict "Class" "fa-solid fa-cloud-download-alt ms-1 text-secondary" | partial "plugin/icon.html" -}}
|
||||
{{- else -}}
|
||||
{{- dict "Class" "fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" | partial "plugin/icon.html" -}}
|
||||
{{- end -}}
|
||||
{{- else if .Download }}
|
||||
{{- dict "Class" "fa-solid fa-download ms-1 text-secondary" | partial "plugin/icon.html" -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $cardIcon := .CardIcon -}}
|
||||
{{- if (not $cardIcon) | and $url.Host -}}
|
||||
{{- with partial "function/get-remote-image.html" (dict "Src" (add "https://favicon.im/" $url.Host)) -}}
|
||||
{{- $cardIcon = .RelPermalink -}}
|
||||
{{- else with partial "function/get-remote-image.html" (dict "Src" (add "https://api.lruihao.cn/google/s2/favicons?sz=64&domain=" $url.Host)) -}}
|
||||
{{- $cardIcon = .RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
<span class="cl-backdrop"></span>
|
||||
<span class="cl-content">
|
||||
<span class="cl-text">
|
||||
<span class="cl-title">
|
||||
{{- with .Icon -}}
|
||||
{{- partial "plugin/icon.html" . }}
|
||||
{{ end -}}
|
||||
{{- with .Content -}}
|
||||
{{- . | safeHTML -}}
|
||||
{{- end -}}
|
||||
</span>
|
||||
<span class="cl-meta">
|
||||
<svg class="cl-icon-link" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M574 665.4c-3.1-3.1-8.2-3.1-11.3 0L446.5 781.6c-53.8 53.8-144.6 59.5-204 0-59.5-59.5-53.8-150.2 0-204l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3l-39.8-39.8c-3.1-3.1-8.2-3.1-11.3 0L191.4 526.5c-84.6 84.6-84.6 221.5 0 306s221.5 84.6 306 0l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3L574 665.4zM832.6 191.4c-84.6-84.6-221.5-84.6-306 0L410.3 307.6c-3.1 3.1-3.1 8.2 0 11.3l39.7 39.7c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c53.8-53.8 144.6-59.5 204 0 59.5 59.5 53.8 150.2 0 204L665.3 562.6c-3.1 3.1-3.1 8.2 0 11.3l39.8 39.8c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c84.5-84.6 84.5-221.5 0-306.1z" fill="#a9a9b3"></path><path d="M610.1 372.3c-3.1-3.1-8.2-3.1-11.3 0L372.3 598.7c-3.1 3.1-3.1 8.2 0 11.3l39.6 39.6c3.1 3.1 8.2 3.1 11.3 0l226.4-226.4c3.1-3.1 3.1-8.2 0-11.3l-39.5-39.6z" fill="#a9a9b3"></path></svg>
|
||||
<span class="cl-url">
|
||||
{{- $u := urls.Parse .Destination -}}
|
||||
{{- $u.String | safeURL | strings.TrimPrefix (add $u.Scheme "://") -}}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
{{- if .Download -}}
|
||||
<svg class="cl-shortcut-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="64" height="64"><path d="M824.32 473.6c-15.36-2.56-25.6-15.36-25.6-30.72 0-112.64-71.68-217.6-179.2-250.88-148.48-46.08-289.28 38.4-332.8 166.4-2.56 10.24-12.8 17.92-23.04 20.48C143.36 401.92 51.2 509.44 51.2 637.44v2.56c0 115.2 97.28 204.8 209.92 204.8h524.8c102.4-2.56 184.32-84.48 184.32-186.88 2.56-89.6-61.44-163.84-145.92-184.32z m-273.92 225.28c-12.8 12.8-30.72 15.36-46.08 10.24H501.76c-5.12-2.56-10.24-5.12-15.36-10.24L366.08 578.56c-15.36-15.36-15.36-43.52 0-58.88 15.36-15.36 43.52-15.36 58.88 0l51.2 51.2V352.4608c0-23.04 17.92-40.96 40.96-40.96 23.04 0 40.96 17.92 40.96 40.96v218.4192l51.2-51.2c17.92-17.92 43.52-17.92 61.44 0 17.92 15.36 17.92 40.96 0 58.88l-120.32 120.32z" fill="#4FC089"></path></svg>
|
||||
{{- else -}}
|
||||
{{- with $cardIcon -}}
|
||||
{{- if (strings.HasPrefix . "fa") -}}
|
||||
<i class="{{ . }} cl-shortcut-icon"></i>
|
||||
{{- else -}}
|
||||
<img src="{{ . }}" alt="card image" class="cl-shortcut-image">
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
<svg class="cl-shortcut-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="64" height="64"><path d="M960 512c0 249.408-203.2 448-448 448-244.778667 0-448-198.592-448-448S262.592 64 512 64s448 198.592 448 448" fill="#2196F3"></path><path d="M507.52 718.08c0-8.96-4.48-13.44-13.44-17.92-26.88-8.96-53.76-8.96-76.16-31.381333-4.48-8.96-4.48-17.92-8.96-26.88-8.96-8.96-31.36-13.44-44.8-17.92h-89.6c-13.44-4.48-22.4-22.4-31.36-35.84 0-4.48 0-13.461333-8.96-13.461334-8.96-4.458667-17.92 4.501333-26.88 0-4.48-4.458667-4.48-8.96-4.48-13.418666 0-13.461333 8.96-26.901333 17.92-35.861334 13.44-8.96 26.88 4.48 40.32 4.48 4.48 0 4.48 0 8.96 4.48 13.44 4.48 17.92 22.4 17.92 35.861334v8.96c0 4.48 4.48 4.48 8.96 4.48 4.48-22.4 4.48-44.821333 8.96-67.2 0-26.88 26.88-53.781333 49.28-62.72 8.96-4.458667 13.44 4.501333 22.4 0 26.88-8.96 94.08-35.84 80.64-71.658667-8.96-31.381333-35.84-62.698667-71.68-58.24-8.96 4.501333-13.44 8.96-22.4 13.461333-13.44 8.96-40.32 35.84-53.76 35.84-22.4-4.48-22.4-35.84-17.92-49.301333 4.48-17.92 44.8-76.138667 71.68-67.178667l17.92 17.92c8.96 4.48 22.4 4.48 35.84 4.48 4.48 0 8.96 0 13.44-4.48 4.48-4.48 4.48-4.48 4.48-8.96 0-13.44-13.44-26.901333-22.4-35.861333s-22.4-17.92-35.84-22.378667c-44.8-13.461333-116.48 4.458667-152.32 35.84-35.84 31.36-62.72 85.12-80.64 129.92-8.96 26.88-17.92 62.698667-22.4 94.08-4.48 22.4-8.96 40.32 4.48 62.698667 13.44 26.88 40.32 53.781333 67.2 71.68 17.92 13.44 53.76 13.44 71.68 35.84 13.44 17.941333 8.96 40.32 8.96 62.72 0 26.88 17.92 49.28 26.88 71.658667 4.48 13.461333 8.96 31.381333 13.44 44.821333 0 4.48 4.48 31.36 4.48 35.84 26.88 13.44 49.28 26.901333 80.64 35.861333 4.48 0 22.4-26.901333 22.4-31.381333 13.44-13.44 22.4-31.36 35.84-40.32 8.96-4.48 17.92-8.96 26.88-17.941333 8.96-8.96 13.44-26.88 17.92-40.32 4.48-8.938667 8.96-26.858667 4.48-40.298667M516.48 305.92c4.48 0 8.96-4.48 17.92-8.96 13.44-8.96 26.901333-22.4 40.32-31.36 13.461333-8.96 26.901333-22.4 35.861333-31.36 13.44-8.96 22.4-26.88 26.88-40.341333 4.48-8.96 17.941333-26.88 13.44-40.32-4.48-8.96-26.88-13.44-35.84-17.92C579.2 126.698667 547.84 122.24 512 122.24c-13.44 0-31.36 4.458667-35.84 17.92-4.48 22.4 13.44 17.92 31.36 22.4 0 0 4.48 35.84 4.48 40.32 4.48 22.421333-8.96 35.84-8.96 58.24 0 13.44 0 35.84 8.96 44.8h4.48zM892.8 619.52c4.501333-8.96 4.501333-22.4 8.96-31.36 4.501333-22.421333 4.501333-44.8 4.501333-67.2 0-44.8-4.501333-89.578667-17.92-129.92-8.96-13.44-13.461333-26.88-17.941333-40.341333-8.96-22.378667-22.4-44.8-40.32-62.698667-17.92-22.4-40.341333-85.12-80.64-67.2-13.44 4.501333-22.4 22.421333-31.36 31.381333l-26.88 40.32c-4.501333 4.48-8.96 13.44-4.501333 17.92 0 4.48 4.501333 4.48 8.96 4.48 8.96 4.501333 13.461333 4.501333 22.421333 8.96 4.48 0 8.96 4.501333 4.48 8.96 0 0 0 4.501333-4.48 4.501334-22.421333 22.4-44.8 40.32-67.2 62.698666-4.48 4.48-8.96 13.44-8.96 17.92s4.48 4.48 4.48 8.96c0 4.501333-4.48 4.501333-8.96 8.96-8.96 4.501333-17.92 8.96-22.4 13.461334-4.48 8.96 0 22.4-4.48 31.36-4.48 22.4-17.941333 40.32-26.901333 62.72-8.96 13.418667-13.418667 26.88-22.378667 40.32 0 17.92-4.501333 31.36 4.458667 44.8 22.421333 31.36 62.72 13.44 94.08 26.901333 8.96 4.458667 17.92 4.458667 22.421333 13.418667 13.418667 13.461333 13.418667 35.861333 17.92 49.301333 4.458667 17.92 8.96 35.84 17.92 53.76 4.48 22.421333 13.44 44.821333 17.92 62.72 40.341333-31.36 76.16-67.178667 103.04-112 26.88-31.424 40.341333-67.242667 53.76-103.104" fill="#CDDC39"></path></svg>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</span>
|
||||
{{- /* External link guard */ -}}
|
||||
{{- $isGuarded := false -}}
|
||||
{{- if
|
||||
$config.guard.enable
|
||||
| and $isExternal
|
||||
| and (not (in $config.guard.allowDomains $url.Host))
|
||||
-}}
|
||||
{{- $isGuarded = true -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $destination := cond $isGuarded (add (relLangURL "link") "?target=" (urlquery .Destination)) .Destination -}}
|
||||
{{- $attrs := printf `href="%s"` ($destination | safeURL) -}}
|
||||
{{- with .Title -}}
|
||||
{{- $attrs = printf ` title="%s"` . | add $attrs -}}
|
||||
{{- end -}}
|
||||
{{- if $isExternal | or .Newtab -}}
|
||||
{{- $attrs = add $attrs ` target="_blank"` -}}
|
||||
{{- end -}}
|
||||
{{- with $rel -}}
|
||||
{{- $attrs = printf ` rel="%s"` (trim . " ") | add $attrs -}}
|
||||
{{- end -}}
|
||||
{{- with $class -}}
|
||||
{{- $attrs = printf ` class="%s"` . | add $attrs -}}
|
||||
{{- end -}}
|
||||
{{- with .Download -}}
|
||||
{{- $attrs = printf ` download="%s"` . | add $attrs -}}
|
||||
{{- end -}}
|
||||
{{- if $isGuarded | and (eq $config.guard.mode "modal") -}}
|
||||
{{- $attrs = add $attrs ` data-guard="modal"` -}}
|
||||
{{- end -}}
|
||||
|
||||
<a {{ $attrs | safeHTMLAttr }}>
|
||||
{{- if eq .Card true -}}
|
||||
{{- template "render-link-card" (dict "ctx" . "url" $url) -}}
|
||||
{{- else -}}
|
||||
{{- template "render-link-regular" (dict "ctx" . "config" $config "isExternal" $isExternal) -}}
|
||||
{{- end -}}
|
||||
</a>
|
||||
{{- /* EOF */ -}}
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
{{- end -}}
|
||||
{{- $destination = printf (string $template) .Id -}}
|
||||
{{- end -}}
|
||||
{{- dict "Destination" $destination "Rel" "me" | merge . | partial "plugin/link.html" -}}
|
||||
{{- dict "Destination" $destination "Rel" "me" "ExternalIcon" false | merge . | partial "plugin/link.html" -}}
|
||||
|
||||
Reference in New Issue
Block a user