Explorar el Código

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 hace 2 años
padre
commit
4bdf7e86c3
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  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>