@Anne-Laure : I suspect we have been overcomplicating a bit because most of 
us are not familiar with the static site generation process. If you can 
walk us through a few details of your setup I think we are close a 
solution. Short instructions at the end, but please read through everything.

Have you modified this template
 static.tiddler.html

from the folder 
/core/templates?

If so, please post your customized template. If not, where exactly are you 
using regexp to replace the spaces in file names, and the links to them, 
with hyphens?

TiddlyWiki defines three variables that can be used to tweak the structure 
of url's in the static files generated:
https://tiddlywiki.com/#tv-wikilink-template%20Variable:%5B%5Btv-wikilink-template%20Variable%5D%5D%20%5B%5Btv-filter-export-link%20Variable%5D%5D%20%5B%5Btv-get-export-link%20Variable%5D%5D

You said you have replaced the spaces in tiddler names with hyphens, the 
correct way to do this in links would be via the variable
tv-filter-export-link

https://tiddlywiki.com/#tv-filter-export-link%20Variable used at the top of 
static.tiddler.html as follows:

\define tv-filter-export-link() [split[ ]join[-]encodeuricomponent[]]

Assuming it is setup this way, the following filter will get you the file 
name portion of the url:
[<currentTiddler>subfilter<tv-filter-export-link>]

Since TW doesn't know where your files will be served we need to add in the 
domain name:
[<currentTiddler>subfilter<tv-filter-export-link>addprefix[https:
//www.mentalnodes.com/]]

a better way to do this would be to create a tiddler called something like 
$:/config/static/domain and give it the text value https://mentalnodes.com/ 
so that we can re-use and easily change the domain name.
Then the filter for the URL becomes:
[<currentTiddler>subfilter<tv-filter-export-link>addprefix{$:/config/static/
domain}]


*Putting it all together: (and assuming you aren't doing anything elsewhere 
to tweak the file names)*
At the top of your template:

\define tv-filter-export-link() [split[ ]join[-]encodeuricomponent[]]

\define tweet-this(url,title,description)
<a href=
"https://twitter.com/intent/tweet?source=$url$&text=$title$%20$description$&via=anthilemoon";
 
target="_blank" title="Tweet"><img alt="Tweet" src=
"social-icons/Twitter.png" /></a>
\end


Use as: 

<$macrocall $name="tweet-this" url={{{ [<currentTiddler>subfilter
<tv-filter-export-link>addprefix{$:/config/static/domain}] }}} 
title={{!!title}} description={{!!description}} />

To get your file names to match, you can use this filter with the 
RenderCommand when generating static files:
https://tiddlywiki.com/#RenderCommand

"[split[ ]join[-]encodeuricomponent[]addsuffix[.html]addprefix[static/]]"

For easier access to the url in the template, you can wrap a set widget 
around the entirety of the html portion of your template:
\define macros go here

<$set name="url" filter=
"""[<currentTiddler>subfilter<tv-filter-export-link>addprefix{$:/config/static/domain}]"""
>
<!------html starts here-->


<<url>> will give you the url, relies on tv-filter-export-link being defined 
in the template


</$set>


Please let us know if that works. If so, it can likely be further 
simplified for re-use like placing the site domain in a configuration 
tiddler rather than directly inside the filter

Regards,
Saq

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/397d486c-6e31-45d0-84e8-d1501b80f6c5%40googlegroups.com.

Reply via email to