Slugify wikilinks in static site

tl;dr How can I use the slugify macro in the wikilinks of my static site?

I’m using the slugify[] filter to build my static site:

    "build": {
        "static": [
            "--render", "$:/core/templates/static.template.html", "index.html", "text/plain",
            "--render", "[!is[system]]", "[slugify[]addprefix[static/]addsuffix[.html]]", "text/plain", "$:/core/templates/static.tiddler.html",
            "--render", "$:/core/templates/static.template.css", "static/static.css", "text/plain"
        ]
    }

This is working fine, and creates clean filenames (static/foo-bar.html for [[Foo Bar]]). The links within the tiddlers themselves (and the main index file) are currently broken: [[Foo Bar]] should link to static/foo-bar.html but it links to static/Foo%20Bar.html.

static.tiddler.html is using \define tv-wikilink-template() $uri_doubleencoded$.html. Can I call the slugify macro within this macro definition, or is it more work to get my wikilinks to match my slugified file names?

Ah, got it. There’s a tv-filter-export-link in core/modules/widgets/link.js. I missed this one in the docs, I think I glossed over it while reading about tv-get-export-link and tv-wikilink-template.

$:/core/templates/static.tiddler.html:

\define tv-filter-export-link() [slugify[]addsuffix[.html]]

$:/core/templates/static.template.html:

\define tv-filter-export-link() [slugify[]addprefix[static/]addsuffix[.html]
2 Likes

I’ll pretend I understand.
Welcome to the tiddlyverse :slight_smile: or at least these forums. :slight_smile: