@Anne-Laure this MIGHT work since you have those javascript macros in place 
(and if you want to keep them).

skip all of my directions and do this:

\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

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

or for quick testing without the $:/config/static/domain tiddler:

<$macrocall $name="tweet-this" url={{{ [<tv-get-export-link>addprefix[
https://www.mentalnodes.com]] }}} title={{!!title}} 
description={{!!description}} />

You may need to tweak that filter to remove a . or / character with 
removeprefix

Regards,
Saq

On Saturday, April 25, 2020 at 11:11:56 AM UTC+2, Anne-Laure Le Cunff wrote:
>
> Hi Saq,
>
> First, thanks so much for your help!
>
> Yes, I have modified *static.tiddler.html* - it looks like this 
> <https://github.com/anthilemoon/tw-experiments/blob/master/%24__ness_labs_template_static-view-template.tid>
>  
> in my setup — and it looks like your approach is working! Thank you! Will 
> keep on tweaking, but if you're curious you can see here 
> <https://github.com/anthilemoon/tw-experiments> the files where I did the 
> regex edits. (following these instructions 
> <https://www.didaxy.com/exporting-static-sites-from-tiddlywiki-part-5>)
>
> Many thanks!
>
> On Saturday, April 25, 2020 at 9:37:44 AM UTC+1, Saq Imtiaz wrote:
>>
>> @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.
>>
>> 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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/69c04854-45d1-4032-ac89-bb012931e0b9%40googlegroups.com.

Reply via email to