Building this Website (4. tags)

Friday, May 1, 2015

This is a series of posts which technically describes how Not Even Odd is built. It is primarily meant as a guide for static website creation using TiddlyWiki.

Tags

In TiddlyWiki, tags are highly dynamic but during the static generation, tags turn out as buttons with no action. This thus needs some correcting.

Probing into TiddlyWiki, I figured the displaying of tags is controlled by the shadow tiddler $:/core/ui/TagTemplate(local) (v5.1.8) (current TW).

There, it's not too hard to locate the tag button. I thus I just replaced the button widget

<$button popup=<<qualify "$:/state/popup/tag">> class="tc-btn-invisible tc-tag-label" style=<<tag-styles>>>
<$transclude tiddler={{!!icon}}/> <$view field="title" format="text" />
</$button>

with a link widget that links to the tiddler corresponding to the tag.

<!-- replacing the tag button with a link -->
<$set name="taglinksto" value={{!!title}}>
  <span class="tc-btn-invisible tc-tag-label" style=<<tag-styles>> >
    <$link to=<<taglinksto>> >
      <$transclude tiddler={{!!icon}}/> <$view field="title" format="text" />
    </$link>
  </span>
</$set>

Of course, modifying this shadow tiddler will also affect the TiddlyWiki used for editing this site and we don't really want that. So one solution I use is to create the above modification in a separate file (called static_tags) and then override the tiddler when invoking the static generation (you ought to create a shell script for it)...

# "overriding" shadow tiddler
cp -i static_tags tiddlers/\$__core_ui_TagTemplate.tid

tiddliwiki --rendertiddlers ...     # static generation

rm -f tiddlers/\$__core_ui_TagTemplate.tid    #clean up

This might not be very elegant but it is good enough.


previous: creating the navigation
next: fixing tiddlers' date

Not Even Odd

Musings and mumblings of a random nerd

Last 10 Posts:

Free Software
Widgets
Flow
Building this Website (7. plugins)
Building this Website (6. external files)
Building this Website (5. tiddlers' date)
Building this Website (4. tags)
Building this Website (3. navigation)
Building this Website (2. template)
Building this Website (1. content selection)

...

Tags
see all tags
    All Posts
    (alphabetically | chronologically)

Follow:          ...

Site Policy