Browse Source

Made it so we can now open the results from the search in a new tab using the middle mouse click or "Open in a new tab" from the right click context menu.

Alejandro Gil 1 year ago
parent
commit
947b495315
1 changed files with 6 additions and 5 deletions
  1. 6 5
      website/search.py

+ 6 - 5
website/search.py

@@ -1,4 +1,4 @@
-from nicegui import __version__, app, background_tasks, events, ui
+from nicegui import __version__, background_tasks, events, ui
 
 
 class Search:
@@ -58,11 +58,12 @@ class Search:
                 for result in results:
                     if result['item']['content']:
                         href: str = result['item']['url']
-                        with ui.element('q-item').props('clickable') \
+                        with ui.link(target=href).props('clickable') \
                                 .on('click', lambda href=href: self.open_url(href), []):
-                            with ui.element('q-item-section'):
-                                ui.label(result['item']['title']).style('font-weight: 500')
-                                ui.label(result['item']['content'][:200] + '...').classes('text-grey')
+                            with ui.element('q-item').props('clickable'):
+                                with ui.element('q-item-section'):
+                                    ui.link(result['item']['title'], target=href).style('font-weight: 500')
+                                    ui.markdown(result['item']['content'][:200] + '...').classes('text-grey-1')
 
         background_tasks.create_lazy(handle_input(), name='handle_search_input')