mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-02-22 13:53:23 +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(rehypeSanitize, sanitizeSchema())
|
||||||
.use(rehypeKatex)
|
.use(rehypeKatex)
|
||||||
.use(rehypeMermaid)
|
.use(rehypeMermaid)
|
||||||
.use(rehypeExternalLinks)
|
.use(rehypeExternalLinks, { baseUrl: this.baseUrl })
|
||||||
.use(rehypeStringify)
|
.use(rehypeStringify)
|
||||||
.process(this.content)
|
.process(this.content)
|
||||||
.then((file) => String(file))
|
.then((file) => String(file))
|
||||||
|
@ -224,7 +224,10 @@ function rehypeExternalLinks(options) {
|
||||||
const url = node.properties.href;
|
const url = node.properties.href;
|
||||||
|
|
||||||
if (isInternalUrl(url)) {
|
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";
|
node.properties["data-phx-link-state"] = "push";
|
||||||
} else if (isAbsoluteUrl(url)) {
|
} else if (isAbsoluteUrl(url)) {
|
||||||
node.properties.target = "_blank";
|
node.properties.target = "_blank";
|
||||||
|
|
Loading…
Reference in a new issue