@@ -67,7 +67,7 @@ defmodule AlgoraWeb.DocsLive do
6767 @ impl true
6868 def mount ( % { "path" => [ ] } , _session , socket ) do
6969 docs = Algora.Content . list_content_rec ( "docs" )
70- { :ok , assign ( socket , docs: docs , page_title: "Docs" ) }
70+ { :ok , assign ( socket , docs: docs , page_title: "Docs" , path: [ ] ) }
7171 end
7272
7373 @ impl true
@@ -78,13 +78,15 @@ defmodule AlgoraWeb.DocsLive do
7878
7979 case Algora.Content . load_content ( dir , slug ) do
8080 { :ok , content } ->
81- { :ok , assign ( socket , content: content , page_title: content . title ) }
81+ { :ok , assign ( socket , content: content , page_title: content . title , path: path ) }
8282
8383 { :error , _reason } ->
8484 { :ok , push_navigate ( socket , to: ~p" /docs" ) }
8585 end
8686 end
8787
88+ defp active? ( current_path , href ) , do: Path . join ( [ "/docs" | current_path ] ) == href
89+
8890 defp render_navigation_section ( assigns ) do
8991 ~H"""
9092 < li :for = { section <- nav ( ) } class = "relative mt-6 " >
@@ -98,7 +100,12 @@ defmodule AlgoraWeb.DocsLive do
98100 < li class = "relative " >
99101 < . link
100102 href = { link . href }
101- class = "flex justify-between gap-2 py-1 pr-3 text-sm transition pl-4 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white "
103+ class = {
104+ classes ( [
105+ "flex justify-between gap-2 py-1 pr-3 text-sm transition pl-4 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white" ,
106+ if ( active? ( assigns . path , link . href ) , do: "border-l-2 border-emerald-400" )
107+ ] )
108+ }
102109 >
103110 < span class = "truncate " > { link . title } </ span >
104111 </ . link >
0 commit comments