mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 09:43:06 +00:00
theme: make external link target configurable #426
This commit is contained in:
parent
94e91d5d90
commit
ace996b0ba
5 changed files with 14 additions and 3 deletions
|
@ -86,6 +86,8 @@ Note that some of these parameters are explained in details in other sections of
|
||||||
# If set to true, no index.html will be appended to prettyURLs; this will cause pages not
|
# If set to true, no index.html will be appended to prettyURLs; this will cause pages not
|
||||||
# to be servable from the file system
|
# to be servable from the file system
|
||||||
disableExplicitIndexURLs = false
|
disableExplicitIndexURLs = false
|
||||||
|
# For external links you can define how they are opened in your browser; this setting will only be applied to the content area but not the shortcut menu
|
||||||
|
externalLinkTarget = "_blank"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Serving your page from a subfolder
|
## Serving your page from a subfolder
|
||||||
|
|
|
@ -22,6 +22,9 @@ This document shows you what's new in the latest release. For a detailed list of
|
||||||
|
|
||||||
This added unnessessary complexity. So attachments for leaf bundles in non-multilang setups can now also reside in a `index.files` directory. Although the old `files` directory is now deprecated, if both directories are present, only the old `files` directory will be used for compatiblity.
|
This added unnessessary complexity. So attachments for leaf bundles in non-multilang setups can now also reside in a `index.files` directory. Although the old `files` directory is now deprecated, if both directories are present, only the old `files` directory will be used for compatiblity.
|
||||||
|
|
||||||
|
You can revert back to the old behavior by defining `externalLinkTarget="_self"` in your in the `params` section of your `config.toml`.
|
||||||
|
|
||||||
|
|
||||||
- {{% badge style="note" title=" " %}}Change{{% /badge %}} Absolute links prefixed with `http://` or `https://` are now opened in a separate browser tab.
|
- {{% badge style="note" title=" " %}}Change{{% /badge %}} Absolute links prefixed with `http://` or `https://` are now opened in a separate browser tab.
|
||||||
|
|
||||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The theme now supports [Hugo's module system](https://gohugo.io/hugo-modules/).
|
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The theme now supports [Hugo's module system](https://gohugo.io/hugo-modules/).
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
{{- if and (eq $outputFormat "html") .Site.Params.editURL $File }}
|
{{- if and (eq $outputFormat "html") .Site.Params.editURL $File }}
|
||||||
{{- with $File.Path }}
|
{{- with $File.Path }}
|
||||||
<div id="top-github-link">
|
<div id="top-github-link">
|
||||||
<a class="github-link" title='{{ T "Edit-this-page" }} (CTRL+ALT+w)' href="{{ $Site.Params.editURL }}{{ replace $File.Dir "\\" "/" }}{{ $File.LogicalName }}" target="blank">
|
<a class="github-link" title='{{ T "Edit-this-page" }} (CTRL+ALT+w)' href="{{ $Site.Params.editURL }}{{ replace $File.Dir "\\" "/" }}{{ $File.LogicalName }}" target="_blank">
|
||||||
<i class="fas fa-pen fa-fw"></i>
|
<i class="fas fa-pen fa-fw"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- else if and (eq (len $target) 0) (or (strings.HasPrefix $href "http://") (strings.HasPrefix $href "https://") ) }}
|
{{- else if and (eq (len $target) 0) (or (strings.HasPrefix $href "http://") (strings.HasPrefix $href "https://") ) }}
|
||||||
{{- $target = "_blank" }}
|
{{- $target = "_blank" }}
|
||||||
|
{{- if isset $context.Site.Params "externallinktarget" }}
|
||||||
|
{{- $target = $context.Site.Params.externalLinkTarget }}
|
||||||
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- $title := .title | default ($content) | default ($style | T) }}
|
{{- $title := .title | default ($content) | default ($style | T) }}
|
||||||
{{- $title = trim $title " " }}
|
{{- $title = trim $title " " }}
|
||||||
|
@ -33,7 +36,7 @@
|
||||||
{{- if $isButton }}
|
{{- if $isButton }}
|
||||||
<button{{ if $href }} onclick="{{ $href | safeJS }}"{{ end }}{{ if gt (len $type) 0 }} type="{{ $type }}"{{ end }}>
|
<button{{ if $href }} onclick="{{ $href | safeJS }}"{{ end }}{{ if gt (len $type) 0 }} type="{{ $type }}"{{ end }}>
|
||||||
{{- else }}
|
{{- else }}
|
||||||
<a{{ if $href }} href="{{ $href }}"{{ if gt (len $target) 0 }} target="{{ $target }}" rel="noopener"{{ end }}{{ end }}>
|
<a{{ if $href }} href="{{ $href }}"{{ if gt (len $target) 0 }} target="{{ $target }}"{{ end }}{{ end }}>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if and $icon (eq $iconposition "left") }}
|
{{- if and $icon (eq $iconposition "left") }}
|
||||||
<i class="{{ $icon }}"></i>
|
<i class="{{ $icon }}"></i>
|
||||||
|
|
|
@ -6,5 +6,8 @@
|
||||||
{{- $target := .target | default "" }}
|
{{- $target := .target | default "" }}
|
||||||
{{- if and (eq (len $target) 0) (or (strings.HasPrefix $url "http://") (strings.HasPrefix $url "https://") ) }}
|
{{- if and (eq (len $target) 0) (or (strings.HasPrefix $url "http://") (strings.HasPrefix $url "https://") ) }}
|
||||||
{{- $target = "_blank" }}
|
{{- $target = "_blank" }}
|
||||||
|
{{- if isset $context.Page.Site.Params "externallinktarget" }}
|
||||||
|
{{- $target = $context.Page.Site.Params.externalLinkTarget }}
|
||||||
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
<a href="{{ $url | safeURL }}"{{ if $title }} title="{{ $title }}"{{ end }}{{ if gt (len $target) 0 }} target="{{ $target }}" rel="noopener"{{ end }}>{{ $content | safeHTML }}</a>
|
<a href="{{ $url | safeURL }}"{{ if $title }} title="{{ $title }}"{{ end }}{{ if gt (len $target) 0 }} target="{{ $target }}"{{ end }}>{{ $content | safeHTML }}</a>
|
Loading…
Reference in a new issue