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

Commit 15ff8ab

Browse files
committed
factor out pattern exclusion from buildNavigation()
1 parent ea10c07 commit 15ff8ab

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

core/lib/ui_builder.js

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,14 @@ function buildNavigation(patternlab) {
6565
var pattern = patternlab.patterns[i];
6666
var bucketName = pattern.name.replace(/\\/g, '-').split('-')[1];
6767

68+
// skip underscore-prefixed files. don't create a bucket on account of an underscored pattern
69+
if (isPatternExcluded(pattern)) {
70+
continue;
71+
}
72+
6873
//check if the bucket already exists
6974
var bucketIndex = patternlab.bucketIndex.indexOf(bucketName);
7075
if (bucketIndex === -1) {
71-
72-
// skip underscore-prefixed files. don't create a bucket on account of an underscored pattern
73-
if (isPatternExcluded(pattern)) {
74-
continue;
75-
}
76-
7776
//add the bucket
7877
var bucket = new of.oBucket(bucketName);
7978

@@ -172,12 +171,6 @@ function buildNavigation(patternlab) {
172171

173172
//if it is flat - we should not add the pattern to patternPaths
174173
if (flatPatternItem) {
175-
176-
// skip underscore-prefixed files
177-
if (isPatternExcluded(pattern)) {
178-
continue;
179-
}
180-
181174
//add the navItem to patternItems
182175
bucket.patternItems.push(navSubItem);
183176

@@ -187,24 +180,22 @@ function buildNavigation(patternlab) {
187180
} else {
188181

189182
// only do this if pattern is included
190-
if (!isPatternExcluded(pattern)) {
191-
//check to see if navItem exists
192-
var navItemIndex = bucket.navItemsIndex.indexOf(navItemName);
193-
if (navItemIndex === -1) {
194-
navItem = new of.oNavItem(navItemName);
195-
196-
//add the navItem and navSubItem
197-
navItem.navSubItems.push(navSubItem);
198-
navItem.navSubItemsIndex.push(navSubItemName);
199-
bucket.navItems.push(navItem);
200-
bucket.navItemsIndex.push(navItemName);
201-
202-
} else {
203-
//add the navSubItem
204-
navItem = bucket.navItems[navItemIndex];
205-
navItem.navSubItems.push(navSubItem);
206-
navItem.navSubItemsIndex.push(navSubItemName);
207-
}
183+
//check to see if navItem exists
184+
var navItemIndex = bucket.navItemsIndex.indexOf(navItemName);
185+
if (navItemIndex === -1) {
186+
navItem = new of.oNavItem(navItemName);
187+
188+
//add the navItem and navSubItem
189+
navItem.navSubItems.push(navSubItem);
190+
navItem.navSubItemsIndex.push(navSubItemName);
191+
bucket.navItems.push(navItem);
192+
bucket.navItemsIndex.push(navItemName);
193+
194+
} else {
195+
//add the navSubItem
196+
navItem = bucket.navItems[navItemIndex];
197+
navItem.navSubItems.push(navSubItem);
198+
navItem.navSubItemsIndex.push(navSubItemName);
208199
}
209200

210201
//check if we are moving to a new sub section in the next loop

0 commit comments

Comments
 (0)