thien-do / memos-pub

Markdown Blogging, Without Setup or Signup
https://memos.pub
116 stars 21 forks source link

feat(mdx): Open absolute links in new tab #34

Closed tuhuynh27 closed 2 years ago

tuhuynh27 commented 2 years ago
[Link](https://memos.pub/)

Current: Links in markdown files open in the same tab. Expected: I think it's better if links in markdown files default to open in a new tab.

thien-do commented 2 years ago

oh that's right, sorry, will look into this

it uses unifiedjs under the hood btw (rehype remark) so maybe there's a related plugin or we can use one of the current plugin (there's one that rewrite relative links, guess it can also be used for this)

thien-do commented 2 years ago

I think this is quite simple and could be a good first issue! We already have logic to alter the links in markdown files, so all we need is focus on this line:

https://github.com/thien-do/memos.pub/blob/0be2f222f1a51eb843c1ef68fc21fe41d8109f8c/lib/mdx/plugins/url.ts#L32

and instead of doing nothing (return), we should add the "target" attribute to the current node.

Two notes: