Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/asurbernardo/amperage.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsur <asur@asurbernardo.com>2020-07-24 21:20:45 +0300
committerAsur <asur@asurbernardo.com>2020-07-24 21:20:45 +0300
commitf84076e2d6dcf4772e68f94dbd8295600a11accb (patch)
tree547bd052036a36480ea93a048db99fe920428323
parent0ee3c3ddc22b10728c31a37408fe4d7961a185b3 (diff)
Create render hook for anchors to add automatic prefetching and rel attribute
-rw-r--r--layouts/_default/_markup/render-link.html9
1 files changed, 9 insertions, 0 deletions
diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html
new file mode 100644
index 0000000..42dfb69
--- /dev/null
+++ b/layouts/_default/_markup/render-link.html
@@ -0,0 +1,9 @@
+{{ $baseUrl := trim .Page.Site.BaseURL "/" }}
+{{ $url := trim .Destination "/" | absURL }}
+
+<a href="{{ $url }}"
+ {{ if hasPrefix $url $baseUrl }} data-rel="prefetch"
+ {{else}} target="_blank" rel="nofollow noopener noreferrer" {{ end }}
+ {{ with .Title}} title="{{ . }}"{{ end }}>
+ {{ .Text | safeHTML }}
+</a> \ No newline at end of file