Skip to content

Commit

Permalink
Render url with .md to correct link (#246)
Browse files Browse the repository at this point in the history
* Render url with .md to correct link

* Fix external link issue

* Update render-link.html

---------

Co-authored-by: Chris Holdgraf <[email protected]>
  • Loading branch information
cmd-ntrf and choldgraf authored May 24, 2024
1 parent cbc07ad commit af2e18f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
{{ $title = replace $title "https://github.com/" "" }}
{{ $title = replace $title "/issues/" "#" }}
{{ $title = replace $title "/pull/" "#" }}
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank" rel="noopener"{{ end }}>{{ $title | safeHTML }}</a>

// This is a custom link resolver that resolves both internal and external links, thanks to @cmd-ntrf for the helpful fix.
<a {{ if strings.HasPrefix .Destination "http" }}href="{{ .Destination | safeURL }}" target="_blank" rel="noopener" {{ else }} href="{{ (.Page.GetPage .Destination).RelPermalink | safeURL }}" {{ end }} {{ with .Title}} title="{{ . }}"{{ end }}>{{ $title | safeHTML }}</a>

0 comments on commit af2e18f

Please sign in to comment.