-
-
Save jensgro/8b591ae4055a56e09dded2d7e0e18de3 to your computer and use it in GitHub Desktop.
Removes index.html from 11ty URL strings to create prettier permalinks. Usage {{url | permalink}} (source: https://paulrobertlloyd.com/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Removes (index).html from a string | |
* | |
* @param {String} str URL, i.e. /page/index.html | |
* @return {String} Permalinkable URL, i.e. /page/ | |
* | |
*/ | |
module.exports = function (str) { | |
return str.replace(/(?:index)?\.html/g, ''); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment