Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit ff36df9

Browse files
committed
factor out navSubItem creation
1 parent 7f78ae5 commit ff36df9

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

core/lib/ui_builder.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,21 @@ function buildNavigation(patternlab) {
7777
var navSubItem;
7878
var navViewAllItem;
7979

80-
//get the navItem
80+
//get the navItem.
8181
//if there is one or more slashes in the subdir, get everything after
8282
//the last slash. if no slash, get the whole subdir string and strip
8383
//any numeric + hyphen prefix
8484
navItemName = pattern.subdir.split('/').pop().replace(/^\d*\-/, '');
85+
8586
//get the navSubItem
8687
navSubItemName = pattern.patternName.replace(/-/g, ' ');
8788

89+
//assume the navSubItem does not exist.
90+
navSubItem = new of.oNavSubItem(navSubItemName);
91+
navSubItem.patternPath = pattern.patternLink;
92+
navSubItem.patternPartial = bucketName + "-" + pattern.patternName; //add the hyphenated name
93+
94+
8895

8996
//check if the bucket already exists
9097
var bucketIndex = patternlab.bucketIndex.indexOf(bucketName);
@@ -105,11 +112,6 @@ function buildNavigation(patternlab) {
105112
//assume the navItem does not exist.
106113
navItem = new of.oNavItem(navItemName);
107114

108-
//assume the navSubItem does not exist.
109-
navSubItem = new of.oNavSubItem(navSubItemName);
110-
navSubItem.patternPath = pattern.patternLink;
111-
navSubItem.patternPartial = bucketName + "-" + pattern.patternName; //add the hyphenated name
112-
113115
//add the patternState if it exists
114116
if (pattern.patternState) {
115117
navSubItem.patternState = pattern.patternState;
@@ -153,11 +155,6 @@ function buildNavigation(patternlab) {
153155
//find the bucket
154156
bucket = patternlab.buckets[bucketIndex];
155157

156-
//assume the navSubItem does not exist.
157-
navSubItem = new of.oNavSubItem(navSubItemName);
158-
navSubItem.patternPath = pattern.patternLink;
159-
navSubItem.patternPartial = bucketName + "-" + pattern.patternName; //add the hyphenated name
160-
161158
//add the patternState if it exists
162159
if (pattern.patternState) {
163160
navSubItem.patternState = pattern.patternState;

0 commit comments

Comments
 (0)