Custom passage link with setter

the default is like this and this works fine
[[Work|Office][$working = 1]]

how to add some icon into te text param ? such
<i class="fas fa-lock-open"></i>

i can add the icon within raw html like this
<a data-passage="Office" class="link-internal" tabindex="0"><i class="fas fa-lock-open"></i> Work</a>

but what about the setter? thx before

and why is this incorrect? this will run on Office and Sleep
<<if passage() isnot "Office" or passage() isnot "Sleep" >>

but this one is correct, this wil not run in Office
<<if passage() isnot "Office">>


You can use the <<link>> macro for that:

<<link '<i class="fas fa-lock-open"></i> Work' 'Office'>>
	<<set $working = 1>>

That will do what you want.

Because the passage name will always not be one or the other of those, or neither of those. Basically, that <<if>> statement can never be false. What you need to write instead is:

<<if passage() isnot "Office" and passage() isnot "Sleep">>

Replacing the “or” with an “and” fixes that. If it helps make it clearer to you, you could do it one of these ways too:

<<if not (passage() is "Office" or passage() is "Sleep")>>
  - or -
<<if not ["Office", "Sleep"].includes(passage())>>

Hope that helps! :grinning:

You can also use HTML Attribute to achieve a similar result…
Your setter link example…

[[Work|Office][$working = 1]]

…can be written as…

<a data-passage="Office" data-setter="$working = 1" class="fas fa-lock-open">Work</a>

…or more precise…

<a data-passage="Office" data-setter="$working = 1" class="link-internal fas fa-lock-open" tabindex="0">Work</a>
1 Like

thx, i dont know i can put the setter in html attribute, nice