Skip to content

Links open in the new tab - #71

Open
zzzsyyy wants to merge 2 commits into
wangchucheng:mainfrom
zzzsyyy:master
Open

Links open in the new tab #71
zzzsyyy wants to merge 2 commits into
wangchucheng:mainfrom
zzzsyyy:master

Conversation

@zzzsyyy

@zzzsyyy zzzsyyy commented Feb 21, 2021

Copy link
Copy Markdown

Open the vast majority of non-internal links in a new tab
add target = "_blank"

reference :#6545

@zzzsyyy zzzsyyy changed the title Create render-link.html Links open in the new tab Feb 21, 2021
@wangchucheng

wangchucheng commented Mar 12, 2021

Copy link
Copy Markdown
Owner

Thanks for this PR! Sorry for the late reply because there are many personal affairs after the Chinese New Year.

People have different opinions about when to open a new window, but this is indeed a useful feature in some situations. I think we can make it configurable.

@RobbiNespu RobbiNespu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative and shorter (one line) is doing like this

<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank"{{ end }}>{{ .Text | markdownify }}</a>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants