From 5143138c1638deeac30d08475bab52ab713c2d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Desmedt?= <34781168+DesignThinkerer@users.noreply.github.com> Date: Fri, 7 Aug 2026 22:05:06 +0200 Subject: [PATCH] [DOCS] Update [[Custom Widgets]] with new example for overriding LinkWidget (#9961) * [DOCS] Update [[Custom Widgets]] with new example for overriding LinkWidget * fix: non-svg link icon are now sizing properly * replace HelloThere by list-link in the example for robustness * Add class to span for better styling in Custom Widgets * Fix typo in Custom Widgets.tid documentation * Improve doc by using the proper macro to link widgets * Change font size style to important for title icon Updated the font size style for the title icon to be important. * Update transclude and slot elements in Custom Widgets Provide a fallback if no body for the link is given * Enhance link widget to show icons conditionally Updated the link widget to conditionally display an icon next to the link based on the target tiddler's icon field. Modified the rendering logic to use a conditional statement for the icon display. * Change transclude height to size in Custom Widgets --- .../tiddlers/widgets/Custom Widgets.tid | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/widgets/Custom Widgets.tid b/editions/tw5.com/tiddlers/widgets/Custom Widgets.tid index 847bdeed96..ab9b5c6fdf 100644 --- a/editions/tw5.com/tiddlers/widgets/Custom Widgets.tid +++ b/editions/tw5.com/tiddlers/widgets/Custom Widgets.tid @@ -1,5 +1,5 @@ created: 20221007144237585 -modified: 20240422084734129 +modified: 20260807190532419 tags: Concepts title: Custom Widgets type: text/vnd.tiddlywiki @@ -79,3 +79,34 @@ Python <$let test="Tiger"> <$codeblock code=<>/> """>> + +In this example, we override the <<.wlink "LinkWidget">> widget to automatically display an icon next to the link if the target tiddler has an `icon` field. We use the <<.wlink "ParametersWidget">> widget to capture all attributes passed to the original link and forward them to the underlying widget via <<.wlink "GenesisWidget">>: + +<jsonget[to]elseget[icon]] +\end link.icon +\function link.text() +[jsonget[to]else] +\end link.text +\whitespace trim +<$parameters $params="params-var"> + <$genesis + $type="$link" + $remappable="no" + $names="[jsonindexes[]]" + $values="[jsonindexes[]] :map[jsonget]" + > + <%if []%> + + <$transclude $tiddler=<> size="11pt"/> + + <%endif%> + <$slot $name="ts-raw"> + <$text text=<> /> + + + +\end + +<>""">>