Non-ASCII paths sluggification

This page is created from a file called "Не АСКИ файл.md" ("non-ASCII file" in Russian), but as you can see the URL contains "ne-aski-fayl" instead.

Заголовок с эмодзи 🥸

And the heading above also has properly sluggified ID in the generated HTML code:

<h3 id="zagolovok-s-emodzi-disguised_face">...</h3>

These things are possible thanks to the anyslug plugin.

How to use

Use the module and its 2 nodes for your pipeline:

anyslug = require("anyslug")

...

return {
    ...
    anyslug.sluggifyPaths(),
    ...
    anyslug.sluggifyLinks(),
    ...
}

When you require the module it uses a little hack to inject the implementation of sluggify function provided by the module into Luasmith, that's how headings' IDs with non-ASCII characters also get sluggified properly.

  1. sluggifyPaths

    This node walks over all items and sluggifies their paths. It should be executed before any other nodes that collects items' paths (like aggregate).

    If you use anyslug together with i18n module, then i18n.localize must be used before anyslug.sluggifyPaths, otherwise pages' language suffixes will be malformed.

  2. sluggifyLinks

    This node sluggifies all links in items' content. It should be used closer to the end of your pipeline, after applying templates and doing other stuff that changes content.