add backlinks
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| defmodule MemexWeb.ContextLive.Show do | ||||
|   use MemexWeb, :live_view | ||||
|   alias Memex.Contexts | ||||
|   alias Memex.{Contexts, Pipelines} | ||||
|  | ||||
|   @impl true | ||||
|   def mount(_params, _session, socket) do | ||||
| @@ -23,7 +23,9 @@ defmodule MemexWeb.ContextLive.Show do | ||||
|       socket | ||||
|       |> assign( | ||||
|         context: context, | ||||
|         page_title: page_title(live_action, context) | ||||
|         page_title: page_title(live_action, context), | ||||
|         context_backlinks: Contexts.backlink("[#{context.slug}]", current_user), | ||||
|         pipeline_backlinks: Pipelines.backlink("[[#{context.slug}]]", current_user) | ||||
|       ) | ||||
|  | ||||
|     {:noreply, socket} | ||||
|   | ||||
| @@ -11,6 +11,27 @@ | ||||
|  | ||||
|   <.context_content context={@context} /> | ||||
|  | ||||
|   <div | ||||
|     :if={@context_backlinks ++ @pipeline_backlinks != []} | ||||
|     class="flex flex-wrap justify-end items-center self-end" | ||||
|   > | ||||
|     <p><%= gettext("Backlinked by:") %></p> | ||||
|     <.link | ||||
|       :for={backlink <- @context_backlinks} | ||||
|       class="m-1 hover:underline" | ||||
|       patch={~p"/context/#{backlink}"} | ||||
|     > | ||||
|       <%= gettext("[%{slug}]", slug: backlink.slug) %> | ||||
|     </.link> | ||||
|     <.link | ||||
|       :for={backlink <- @pipeline_backlinks} | ||||
|       class="m-1 hover:underline" | ||||
|       patch={~p"/pipeline/#{backlink}"} | ||||
|     > | ||||
|       <%= gettext("[[%{slug}]]", slug: backlink.slug) %> | ||||
|     </.link> | ||||
|   </div> | ||||
|  | ||||
|   <p class="self-end"> | ||||
|     <%= gettext("Visibility: %{visibility}", visibility: @context.visibility) %> | ||||
|   </p> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user