Skip to content

Commit 5e64475

Browse files
authored
feat: site dropdown attrs (#1534)
1 parent ffe1be4 commit 5e64475

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

docs/configuration/site-dropdown.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ UNFOLD = {
2525
"icon": "diamond",
2626
"title": _("My site"),
2727
"link": "https://example.com",
28+
"attrs": {
29+
"target": "_blank",
30+
},
2831
},
2932
{
3033
"icon": "diamond",

src/unfold/dataclasses.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ class DropdownItem:
3939
title: str
4040
link: Union[str, Callable]
4141
icon: Optional[str] = None
42+
attrs: Optional[dict] = None

src/unfold/sites.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ def _get_site_dropdown_items(self, key: str, *args) -> list[dict[str, Any]]:
578578
title=item.get("title"),
579579
link=self._get_value(item["link"], *args),
580580
icon=item.get("icon"),
581+
attrs=item.get("attrs"),
581582
)
582583
for item in items
583584
]

src/unfold/templates/unfold/helpers/site_dropdown.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% if site_dropdown %}
44
<div class="absolute bg-white border border-base-200 flex flex-col left-3 py-1 rounded-default shadow-lg top-[73px] w-[264px] z-50 dark:bg-base-800 dark:border-base-700" x-cloak x-show="openDropdown" x-transition x-on:click.outside="openDropdown = false">
55
{% for item in site_dropdown %}
6-
<a href="{{ item.link }}" class="flex flex-row items-center gap-3 max-h-[30px] mx-1 px-2 py-2 rounded-default text-font-default-light dark:text-font-default-dark hover:bg-base-100 hover:text-font-important-light dark:hover:bg-base-700 dark:hover:text-font-important-dark">
6+
<a href="{{ item.link }}" class="flex flex-row items-center gap-3 max-h-[30px] mx-1 px-2 py-2 rounded-default text-font-default-light dark:text-font-default-dark hover:bg-base-100 hover:text-font-important-light dark:hover:bg-base-700 dark:hover:text-font-important-dark" {% include "unfold/helpers/attrs.html" with attrs=item.attrs %}>
77
{% if item.icon %}
88
<span class="material-symbols-outlined">
99
{{ item.icon }}

0 commit comments

Comments
 (0)