From 7282c89d2bd45bd8503ac47dd7875b3d134f3dcc Mon Sep 17 00:00:00 2001 From: Will Faught Date: Fri, 15 Sep 2023 22:04:50 -0700 Subject: [PATCH] Add external_link_new_tab param --- README.md | 1 + layouts/_default/_markup/render-link.html | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 layouts/_default/_markup/render-link.html diff --git a/README.md b/README.md index ff823fd7..ca6c6136 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,7 @@ There is a single parameter object with sensible defaults that can be overridden ```toml [paige] color = "#0d6efd" # Bootstrap primary color and theme color for Safari and Windows +external_link_new_tab = false # Open external links in new tabs math = false # Enable math typesetting style = "" # CSS included at the end of the stylesheet, before style-last.css diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html new file mode 100644 index 00000000..9cc0acd1 --- /dev/null +++ b/layouts/_default/_markup/render-link.html @@ -0,0 +1,6 @@ +{{ $external := false }} +{{ if (urls.Parse .Destination).IsAbs }} + {{ $external = not (strings.HasSuffix .Destination site.BaseURL) }} +{{ end }} +{{ $newtab := and $external site.Params.paige.external_link_new_tab }} +{{ .Text }}