mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-02-20 21:04:17 +08:00
Rewrite Markdown live links to either push or patch (#1429)
This commit is contained in:
parent
b20ac022a8
commit
61ee3c79dc
1 changed files with 5 additions and 2 deletions
|
@ -65,7 +65,7 @@ class Markdown {
|
|||
.use(rehypeSanitize, sanitizeSchema())
|
||||
.use(rehypeKatex)
|
||||
.use(rehypeMermaid)
|
||||
.use(rehypeExternalLinks)
|
||||
.use(rehypeExternalLinks, { baseUrl: this.baseUrl })
|
||||
.use(rehypeStringify)
|
||||
.process(this.content)
|
||||
.then((file) => String(file))
|
||||
|
@ -224,7 +224,10 @@ function rehypeExternalLinks(options) {
|
|||
const url = node.properties.href;
|
||||
|
||||
if (isInternalUrl(url)) {
|
||||
node.properties["data-phx-link"] = "redirect";
|
||||
node.properties["data-phx-link"] =
|
||||
options.baseUrl && url.startsWith(options.baseUrl)
|
||||
? "patch"
|
||||
: "redirect";
|
||||
node.properties["data-phx-link-state"] = "push";
|
||||
} else if (isAbsoluteUrl(url)) {
|
||||
node.properties.target = "_blank";
|
||||
|
|
Loading…
Reference in a new issue