Skip to content

Commit 0109d6e

Browse files
author
e2tha-e
committed
better rendering of navigation subdirs
1 parent 34793f5 commit 0109d6e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

builder/object_factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
this.subdir = subdir;
1818
this.name = subdir.replace(/[\/\\]/g, '-') + '-' + this.fileName; //this is the unique name with the subDir
1919
this.jsonFileData = data || {};
20-
this.patternName = this.fileName.substring(this.fileName.indexOf('-') + 1); //this is the display name for the ui
20+
this.patternName = this.fileName.replace(/^\d*\-/, ''); //this is the display name for the ui. strip numeric + hyphen prefixes
2121
this.patternLink = this.name + '/' + this.name + '.html';
2222
this.patternGroup = this.name.substring(this.name.indexOf('-') + 1, this.name.indexOf('-', 4) + 1 - this.name.indexOf('-') + 1);
2323
this.patternSubGroup = subdir.substring(subdir.indexOf('/') + 4);

builder/patternlab.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,10 @@ var patternlab_engine = function () {
272272
var bucket = patternlab.buckets[bucketIndex];
273273

274274
//get the navItem
275-
var navItemName = pattern.subdir.split('-').pop();
275+
//if there is one or more slashes in the subdir, get everything after
276+
//the last slash. if no slash, get the whole subdir string and strip
277+
//any numeric + hyphen prefix
278+
var navItemName = pattern.subdir.split('/').pop().replace(/^\d*\-/, '');
276279

277280
//get the navSubItem
278281
var navSubItemName = pattern.patternName.replace(/-/g, ' ');

0 commit comments

Comments
 (0)