mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-31 11:18:57 +08:00
Fix relative link URL in Markdown output (#1189)
This commit is contained in:
parent
07a75887e0
commit
641ac96ae7
3 changed files with 12 additions and 4 deletions
|
@ -13,7 +13,9 @@ const MarkdownRenderer = {
|
|||
mounted() {
|
||||
this.props = this.getProps();
|
||||
|
||||
const markdown = new Markdown(this.el, "");
|
||||
const markdown = new Markdown(this.el, "", {
|
||||
baseUrl: this.props.sessionPath,
|
||||
});
|
||||
|
||||
this.handleEvent(
|
||||
`markdown_renderer:${this.props.id}:content`,
|
||||
|
@ -26,6 +28,7 @@ const MarkdownRenderer = {
|
|||
getProps() {
|
||||
return {
|
||||
id: getAttributeOrThrow(this.el, "data-id"),
|
||||
sessionPath: getAttributeOrThrow(this.el, "data-session-path"),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
|
@ -47,8 +47,12 @@ defmodule LivebookWeb.Output do
|
|||
"""
|
||||
end
|
||||
|
||||
defp render_output({:markdown, markdown}, %{id: id}) do
|
||||
live_component(Output.MarkdownComponent, id: id, content: markdown)
|
||||
defp render_output({:markdown, markdown}, %{id: id, session_id: session_id}) do
|
||||
live_component(Output.MarkdownComponent,
|
||||
id: id,
|
||||
session_id: session_id,
|
||||
content: markdown
|
||||
)
|
||||
end
|
||||
|
||||
defp render_output({:image, content, mime_type}, %{id: id}) do
|
||||
|
|
|
@ -17,7 +17,8 @@ defmodule LivebookWeb.Output.MarkdownComponent do
|
|||
<div class="markdown"
|
||||
id={"markdown-renderer-#{@id}"}
|
||||
phx-hook="MarkdownRenderer"
|
||||
data-id={@id}>
|
||||
data-id={@id}
|
||||
data-session-path={Routes.session_path(@socket, :page, @session_id)}>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue