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.
sluggifyPathsThis 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
anyslugtogether withi18nmodule, theni18n.localizemust be used beforeanyslug.sluggifyPaths, otherwise pages' language suffixes will be malformed.sluggifyLinksThis 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.