defmodule LivebookWeb.SessionLive.ExportComponent do use LivebookWeb, :live_component alias Livebook.Session @impl true def update(assigns, socket) do socket = assign(socket, assigns) socket = if socket.assigns[:notebook] do socket else # Note: we need to load the notebook, because the local data # has cell contents stripped out notebook = Session.get_notebook(socket.assigns.session.pid) assign(socket, :notebook, notebook) end {:ok, socket} end @impl true def render(assigns) do ~H"""

Export

Here you can preview and directly export the notebook source.

<.link patch={~p"/sessions/#{@session.id}/export/livemd"} class={["tab", @tab == "livemd" && "active"]} > Live Markdown <.link patch={~p"/sessions/#{@session.id}/export/exs"} class={["tab", @tab == "exs" && "active"]} > IEx session
<.live_component module={component_for_tab(@tab)} id={"export-notebook-#{@tab}"} session={@session} notebook={@notebook} />
""" end defp component_for_tab("livemd"), do: LivebookWeb.SessionLive.ExportLiveMarkdownComponent defp component_for_tab("exs"), do: LivebookWeb.SessionLive.ExportElixirComponent end