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