Răsfoiți Sursa

Add render hook for links

This render hook does two things. First it will automatically set any
same-site links to have its rel attribute be set to me. It also allows
off-site links to have their rel attribute set. It does this by taking
the title value, and using it for the rel instead.
Apis Necros 2 ani în urmă
părinte
comite
4bdf7e86c3
1 a modificat fișierele cu 6 adăugiri și 0 ștergeri
  1. 6 0
      layouts/_default/_markup/render-link.html

+ 6 - 0
layouts/_default/_markup/render-link.html

@@ -0,0 +1,6 @@
+{{- $sameSite := false -}}
+{{- if eq (.Destination | relURL) (.Destination | absURL) }}{{ $sameSite = true }}{{ end -}}
+<a href="{{ .Destination }}"
+    {{- if $sameSite }} target="_blank"
+        {{- with .Title }} rel="{{ . | safeHTML }}"{{ end }}
+    {{- else }} rel="me"{{ end }}>{{.Text | safeHTML}}</a>