@@ -316,8 +316,8 @@ pub fn search(model: Model) {
316316 True -> "Found "
317317 False ->
318318 "Showing first "
319- |> string . append ( int . to_string ( config . per_page ( ) ) )
320- |> string . append ( " out of " )
319+ <> int . to_string ( config . per_page ( ) )
320+ <> " out of "
321321 }
322322 |> string . append ( int . to_string ( count ) )
323323 |> string . append ( " results" )
@@ -467,68 +467,38 @@ fn trash_button(filter: #(String, String)) {
467467 ] )
468468}
469469
470- fn result_card ( model : Model , result : hexdocs . TypeSense ) {
470+ fn result_card ( model : Model , document : hexdocs . Document ) {
471+ let display_url =
472+ "/" <> string . replace ( document . package , "-" , "/" ) <> "/" <> document . ref
473+ let link_url = config . hexdocs_url ( ) <> display_url
474+
471475 html . div ( [ class ( "w-full bg-slate-100 dark:bg-slate-800 rounded-2xl p-4" ) ] , [
472- html . div ( [ class ( "text-slate-700 dark:text-slate-300 text-sm" ) ] , [
473- html . text ( result . document . package ) ,
474- ] ) ,
475- html . h3 (
476+ html . a (
476477 [
477- class (
478- "text-slate-950 dark:text-slate-50 text-xl font-semibold leading-loose mt-1" ,
479- ) ,
478+ attribute . href ( link_url ) ,
479+ class ( "text-green-700 dark:text-green-400 text-sm hover:underline" ) ,
480480 ] ,
481- [ html . text ( result . document . title ) ] ,
481+ [ html . text ( display_url ) ] ,
482482 ) ,
483- // element.unsafe_raw_html(
484- // "",
485- // "p",
486- // [
487- // class(
488- // "mt-4 text-slate-800 dark:text-slate-300 leading-normal line-clamp-2 overflow-hidden",
489- // ),
490- // ],
491- // result.document.doc,
492- // ),
493- html . div (
483+ html . a (
494484 [
485+ attribute . href ( link_url ) ,
495486 class (
496- "mt-2 inline-flex px-3 py-0.5 bg-slate-300 dark:bg-slate-700 rounded-full " ,
487+ "text-blue-700 dark:text-blue-300 text-xl font-normal leading-tight mt-1 hover:underline block " ,
497488 ) ,
498489 ] ,
499- [
500- html . span ( [ class ( "text-blue-600 dark:text-blue-400 text-sm" ) ] , [
501- html . text ( result . document . ref ) ,
502- ] ) ,
503- ] ,
490+ [ html . text ( document . title ) ] ,
491+ ) ,
492+ element . unsafe_raw_html (
493+ "" ,
494+ "p" ,
495+ [ class ( "text-slate-800 dark:text-slate-300 leading-normal mt-2" ) ] ,
496+ hexdocs . snippet ( document . doc , model . search_input ) ,
504497 ) ,
505- case result . highlight {
506- hexdocs . Highlights ( doc : Some ( doc ) , .. ) -> {
507- element . unsafe_raw_html (
508- "" ,
509- "p" ,
510- [
511- class (
512- "mt-4 text-slate-800 dark:text-slate-300 leading-normal line-clamp-2 overflow-hidden" ,
513- ) ,
514- ] ,
515- doc . snippet ,
516- )
517- // html.text("Channels are a really good abstraction"),
518- // html.span(
519- // [class("bg-slate-950 text-slate-100 px-1 rounded")],
520- // [html.text("for")],
521- // ),
522- // html.text(
523- // "real-time communication. They are bi-directional and persistent connections between the browser and server...",
524- // )
525- }
526- _ -> element . none ( )
527- } ,
528498 html . div ( [ class ( "mt-4 flex flex-wrap gap-3" ) ] , [
529499 html . button (
530500 [
531- event . on_click ( msg . UserToggledPreview ( result . document . id ) ) ,
501+ event . on_click ( msg . UserToggledPreview ( document . id ) ) ,
532502 class (
533503 "h-10 px-4 py-2.5 bg-slate-100 dark:bg-slate-700 rounded-lg border border-slate-300 dark:border-slate-600 flex items-center justify-center" ,
534504 ) ,
@@ -541,35 +511,12 @@ fn result_card(model: Model, result: hexdocs.TypeSense) {
541511 card_icon ( "ri-arrow-down-s-line" ) ,
542512 ] ,
543513 ) ,
544- case hex . go_to_link ( result . document ) {
545- Error ( _ ) -> element . none ( )
546- Ok ( link ) ->
547- html . a (
548- [
549- attribute . href ( link ) ,
550- class (
551- "h-10 px-4 py-2.5 bg-slate-100 dark:bg-slate-700 rounded-lg border border-slate-300 dark:border-slate-600 flex items-center justify-center" ,
552- ) ,
553- ] ,
554- [
555- html . span (
556- [
557- class (
558- "text-slate-800 dark:text-slate-200 text-sm font-semibold" ,
559- ) ,
560- ] ,
561- [ html . text ( "Go to Page" ) ] ,
562- ) ,
563- card_icon ( "ri-external-link-line" ) ,
564- ] ,
565- )
566- } ,
567514 ] ) ,
568- case dict . get ( model . search_opened_previews , result . document . id ) {
515+ case dict . get ( model . search_opened_previews , document . id ) {
569516 Ok ( False ) | Error ( _ ) -> element . none ( )
570517 Ok ( True ) -> {
571518 case
572- hex . preview_link ( result . document , case model . dark_mode . mode {
519+ hex . preview_link ( document , case model . dark_mode . mode {
573520 msg . Dark -> "dark"
574521 msg . Light -> "light"
575522 } )
@@ -581,7 +528,7 @@ fn result_card(model: Model, result: hexdocs.TypeSense) {
581528 [
582529 iframe . iframe ( [
583530 iframe . to ( link ) ,
584- iframe . title ( result . document . package ) ,
531+ iframe . title ( document . package ) ,
585532 ] ) ,
586533 ] ,
587534 )
0 commit comments