Skip to content

Commit

Permalink
Open external links in separate tab; show a SVG icon after the extern…
Browse files Browse the repository at this point in the history
…al link.
  • Loading branch information
frankslin committed Aug 4, 2023
1 parent 630e450 commit 89aab9c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions assets/css/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ a {
}
}

a.external {
background-image: url(/images/external-link.svg?uNJ);
background-position: center right;
background-repeat: no-repeat;
background-size: 0.857em;
padding-right: 1em;
}


// Browsers seem to use a smaller default font-size with monospaced code
// blocks (like 80% of the size of normal text) and that looks pretty bad with
// small inline code-blocks in the middle of normal text (mainly because of
Expand Down
5 changes: 5 additions & 0 deletions layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<a href="{{ .Destination | safeURL }}"
{{ with .Title }} title="{{ . }}"{{ end }}
{{ if or (strings.HasPrefix .Destination "http:") (strings.HasPrefix .Destination "https:") }}
target="_blank" class="external"
{{ end }} >{{ .Text | safeHTML }}</a>
5 changes: 5 additions & 0 deletions static/images/external-link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 89aab9c

Please sign in to comment.