better class generation and remove duplicate class

This commit is contained in:
Pierre Bondoerffer
2017-08-04 15:06:58 +02:00
parent 10e50fc5c7
commit c953e71a18
2 changed files with 11 additions and 10 deletions

View File

@@ -80,8 +80,9 @@ $(function () {
}
} else {
// add class on info-pages
var css = location.pathname.replace(/(\/$|^\/|.html$)/gm, "")
.replace(/[^a-zA-Z]/gi, "-");
var css = location.pathname.replace(/(index)?\.html$/gi, "") // .html
.replace(/[^a-zA-Z]+/gi, '-') // any non-alpha character
.replace(/^-|-$/g, ''); // starting/trailing dashes
if (css === '')
{
css = 'index';