@@ -39,7 +39,7 @@ const Pattern = function(relPath, data, patternlab) {
39
39
40
40
// this is the unique name, subDir + fileName (sans extension)
41
41
this . name = '' ;
42
- if ( info . hasDir ) {
42
+ if ( info . hasDir && info . dirLevel > 2 ) {
43
43
let variant = '' ;
44
44
45
45
if ( this . fileName . indexOf ( '~' ) !== - 1 ) {
@@ -76,23 +76,24 @@ const Pattern = function(relPath, data, patternlab) {
76
76
. trim ( ) ; //this is the display name for the ui. strip numeric + hyphen prefixes
77
77
78
78
//00-atoms if needed
79
- this . patternType = this . getDirLevel ( 0 , info ) ;
79
+ this . patternType = this . getDirLevel ( 0 ) ;
80
80
81
81
// the top-level pattern group this pattern belongs to. 'atoms'
82
82
this . patternGroup = this . patternType . replace ( patternPrefixMatcher , '' ) ;
83
83
84
84
//00-colors if needed
85
- this . patternSubType = this . getDirLevel ( 1 , info ) ;
85
+ this . patternSubType = this . getDirLevel ( 1 ) ;
86
86
87
87
// the sub-group this pattern belongs to.
88
88
this . patternSubGroup = this . patternSubType . replace ( patternPrefixMatcher , '' ) ; // 'global'
89
89
90
90
// the joined pattern group and subgroup directory
91
- this . flatPatternPath = info . hasDir
92
- ? this . subdir
93
- . replace ( / [ / \\ ] / g, '-' )
94
- . replace ( new RegExp ( '-' + info . dir + '$' ) , '' )
95
- : this . subdir . replace ( / [ \/ \\ ] / g, '-' ) ; // '00-atoms-00-global'
91
+ this . flatPatternPath =
92
+ info . hasDir && info . dirLevel > 2
93
+ ? this . subdir
94
+ . replace ( / [ / \\ ] / g, '-' )
95
+ . replace ( new RegExp ( '-' + info . dir + '$' ) , '' )
96
+ : this . subdir . replace ( / [ \/ \\ ] / g, '-' ) ; // '00-atoms-00-global'
96
97
97
98
// calculated path from the root of the public directory to the generated
98
99
// (rendered!) html file for this pattern, to be shown in the iframe
@@ -214,11 +215,8 @@ Pattern.prototype = {
214
215
return this . engine . findPartial ( partialString ) ;
215
216
} ,
216
217
217
- getDirLevel : function ( level , info ) {
218
+ getDirLevel : function ( level ) {
218
219
const items = this . subdir . split ( path . sep ) ;
219
- if ( info . hasDir ) {
220
- items . pop ( ) ;
221
- }
222
220
223
221
if ( items [ level ] ) {
224
222
return items [ level ] ;
0 commit comments