refactor(article-link): abstract anchor attributes for making article links formattable

This commit is contained in:
ZhenShuo Leo
2025-07-09 23:39:03 +08:00
parent 8d940881a4
commit 35faec527b
4 changed files with 8 additions and 15 deletions

View File

@@ -0,0 +1,5 @@
{{ with .Params.externalUrl }}
href="{{ . }}" target="_blank" rel="external"
{{ else }}
href="{{ .RelPermalink }}"
{{- end -}}

View File

@@ -1,8 +1,4 @@
{{ with .Params.externalUrl }}
<a href="{{ . }}" target="_blank" rel="external" class="min-w-full">
{{ else }}
<a href="{{ .RelPermalink }}" class="min-w-full">
{{ end }}
<a {{ partial "article-link/_external-link.html" . | safeHTMLAttr }} class="min-w-full">
<div class="min-h-full border border-neutral-200 dark:border-neutral-700 border-2 rounded overflow-hidden shadow-2xl relative">
{{- with $.Params.images -}}

View File

@@ -1,8 +1,4 @@
{{ with .Params.externalUrl }}
<a href="{{ . }}" target="_blank" rel="external" class="min-w-full">
{{ else }}
<a href="{{ .RelPermalink }}" class="min-w-full">
{{ end }}
<a {{ partial "article-link/_external-link.html" . | safeHTMLAttr }} class="min-w-full">
<div class="min-h-full border border-neutral-200 dark:border-neutral-700 border-2 rounded overflow-hidden shadow-2xl relative">
{{- with $.Params.images -}}

View File

@@ -26,11 +26,7 @@
{{ end }}
{{ with .Params.externalUrl }}
<a class="{{ $articleClasses }}" href="{{ . }}" target="_blank" rel="external">
{{ else }}
<a class="{{ $articleClasses }}" href="{{ .RelPermalink }}">
{{ end }}
<a class="{{ $articleClasses }}" {{ partial "article-link/_external-link.html" . | safeHTMLAttr }}>
{{- with $.Params.images -}}
{{- range first 6 . }}
<meta property="og:image" content="{{ . | absURL }}" />{{ end -}}