Created
February 15, 2019 10:51
-
-
Save danfascia/5d6813d5e0ab779650bd510370c24dff 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 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