kookma/TW-Scripts

Add solution based on making permanent links

Closed this issue · 3 comments

Documents this discussion on the forum: Relink vs Permanent


created: 20210506113300303
keywords: link url
modified: 20210506121255393
responder: [[Anjar]]
tags: solution
title: Use created field to create permanent links to tiddlers
url: https://groups.google.com/g/tiddlywiki/c/QOzs3CVtosU

With the relink plugin, it is easy to change tiddler titles without breaking internal links in your wiki. But what if you have shared a permalink URL? This link breaks if you change tiddler title.

!!Use filter in URL to link to created date

* Copy the URL in the browser of your wiki
* After the '#' symbol add: `:[created[]]`. Between the brackets after created paste the number that it is the `created` field of your tiddler. You can find this value if you look at the `fields` tab after pressing `info` in the view toolbar.
** Example: https://kookma.github.io/TW-Scripts/#:[create[20210506113300303]]
** This wil link to this tiddler.
* In most cases, the value in the `created` is unique. 

!!Use a field to store a unique number to link to

The code below can be used to create a new permalink button that adds a field to the linked tiddler called `permalink`. It combines the tiddler title and created date to create a unique value to link to. This value remains unchanged even after changing the title. It also prevents accidentally linking to tiddlers that have the same creation date (unlikely, but it could happen).

It copies the new permanent link to your clipboard to share.

\whitespace trim
\define permlink() <$text text={{{ [all[current]slugify[]] }}} />-<$text text={{!!created}} />
\define permurl() {{$:/info/url/full}}#:[contains:permalink[$(permaval)$]]

<$button tooltip={{$:/language/Buttons/Permalink/Hint}} aria-label={{$:/language/Buttons/Permalink/Caption}} class=<> >
<$wikify name="permaval" text=<> >
<$wikify name="permaurl" text=<> >
<$action-listops $field="permalink" $subfilter=<> />
<$action-sendmessage $message="tm-copy-to-clipboard" $param=<> />
</$wikify>
</$wikify>
<$list filter="[match[yes]]">
{{$:/core/images/permalink-button}}
</$list>
<$list filter="[match[yes]]">

<$text text=" "/>
<$text text={{$:/language/Buttons/Permalink/Caption}}/>

</$list>
</$button>



The backticks to create a codeblock from the tiddler interfere with those from github. The code in the tiddler should be an codeblock

Thank you Odin! I did this before!

A Permalink Using Created Date.zip

I look in this and merge with the present one!

Sorry for no updating sooner! I pushed updates within few months, no I will do in shorter period and we can keep in touch for future updates

I added this to TW-Scripts!
For detail code, I have added link to the discussion!