Idea: typed links

235 views
Skip to first unread message

Soren Bjornstad

unread,
Feb 27, 2021, 2:32:13 PM2/27/21
to TiddlyWiki
Occasionally I find myself wishing I could include additional information with a link, often describing the exact relationship expressed by the link. A basic example would be, in a journal tiddler, I might link to a person and want to keep track of whether the person actually participated in the events being described, or was just mentioned in them.

I imagine a syntax something like this:

Mentioning [[Alice!mention]].
Or [[a person|Alice!mention]].

Another sensible choice could be to expose this functionality only through the <$link> widget, so that no new syntax would need to be introduced.

You would then be able to filter on this metadata through a suffix of the links[] or backlinks[] operator, e.g., the filter "[[Alice]backlinks:mention[]]" could return only those links to Alice that are of the mention type. Perhaps something like "[linktype[LinkingTiddler],[Alice]]" to retrieve the type value as well (could have multiple values if there are multiple links of different types).

I don't think there is anything you would be able to do with this that you can't do with fields, but I think in quite a few cases this would be a more convenient syntax. Another advantage in some cases is that the metadata would automatically come along with excisions and copy-paste.

Does this sound interesting to anyone else? Practical?

si

unread,
Feb 27, 2021, 4:36:48 PM2/27/21
to TiddlyWiki
Yeah I have also had this thought. When I use fields I always think of them as "typed" links, but without the benefit of any textual context.

If I recall Roam Research has an "attributes" syntax, where something like "attribute::Hello" will behave exactly like a link to "Hello". Presumably they intend to add functionality that allows you to use attributes in the kinds of ways that you suggest.

I don't actually do this, but I have considered writing links like "participant::[[Alice]]" then using the search filter to get thinks like backlinks. E.g:

<$vars search-term="participant::[[Alice]]">
{{{ [search<search-term>] -[<currentTiddler>]}}}
</$vars>

This could be turned into a more general macro of course.

I'm not sure how I feel about using the <$link> widget though. One of the benefits of links over tags is that creating them is a natural part of the writing process, and I think having to type out widget syntax every time you created a link would undermine that.

TW Tones

unread,
Mar 2, 2021, 3:42:33 PM3/2/21
to TiddlyWiki
Soren,

A Quick answer is to create tiddler for the relationship between two tiddlers, link to that relationship, which subsequently links to the related tiddler. Once the relationship tiddler exists exists it is simply a matter of tagging it with Mention or "relationship". The relationship tiddler can be numerically named. 

Alternatively to making generic relationships and tagging them "mention" you could make specific relationships tiddlers eg mentions.

Regards
Tones

si

unread,
Mar 3, 2021, 1:07:35 PM3/3/21
to TiddlyWiki
@Tones I am struggling to understand exactly what you are suggesting. Are you saying that to imitate Soren's example of [[Alice!mention]], you would create a link to a totally unique tiddler, say [[1234]], then tag that tiddler with "mention", then link from that tiddler to [[Alice]]? So you would have a kind of proxy tiddler that represents the "type" of link?

Joshua Fontany

unread,
Mar 3, 2021, 8:53:36 PM3/3/21
to TiddlyWiki
That is a really good option.

```
title: !mentioned

<$link to={{!!title}}><$text text={{!!title}}/> <$transclude field="mentioned"/></$link>
```

```
title: Alice
mentioned: says HI!

Alice is from Alter-space.
```

```
title: Bob

Bob says hi to Alice, so "{{Alice||!mentioned}}"
```


Unfortunately, this does not generate a "backlink" reference because we are using a {{transclusion||template}} to generate the final link widget...

A link is soft if it is:

    ...
  • generated by a link widget whose to attribute is a transclusion, macro or variable

Best,
Joshua Fontany

si

unread,
Mar 5, 2021, 5:12:31 PM3/5/21
to TiddlyWiki
@Joshua Thank you! I think I will use that method. Things like backlinks will be awkward, but do-able as per my previous post. Another issue would be if you wanted to display different text (as in[[Tiddler title|Display string]]). The best I can think of is to use something like ! as a delimiter, and use the following template:

<$vars tiddler={{{ [<currentTiddler>split[!]first[]] }}} caption={{{ [<currentTiddler>split[!]last[]] }}}>
<$link to=<<tiddler>>> <<caption>> </$link>
</$vars>

Then you could use the syntax {{Alice!Display string||relationship-type}}.

@Soren Having said all that, I would love to see something like this either as a plugin or included in the core. Maybe it would be worth making a feature request on GitHub in case there is someone out there who would like to add it, and also has the technical knowledge to do so? What do you think?
On Saturday, 27 February 2021 at 19:32:13 UTC Soren Bjornstad wrote:
Reply all
Reply to author
Forward
0 new messages