Skip to content

Commit 528a60a

Browse files
Merge pull request #455 from /issues/452-viewall
Issues/452 viewall
2 parents 76c79a7 + 59dc7e3 commit 528a60a

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

core/lib/pattern_assembler.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,19 @@ var pattern_assembler = function () {
244244

245245
function processPatternIterative(relPath, patternlab) {
246246

247+
var relativeDepth = relPath.match(/\w(?=\\)|\w(?=\/)/g || []).length;
248+
if (relativeDepth > 2) {
249+
console.log('');
250+
plutils.logOrange('Warning:');
251+
plutils.logOrange('A pattern file: ' + relPath + ' was found greater than 2 levels deep from ' + patternlab.config.paths.source.patterns + '.');
252+
plutils.logOrange('It\'s strongly suggested to not deviate from the following structure under _patterns/');
253+
plutils.logOrange('[patternType]/[patternSubtype]/[patternName].[patternExtension]');
254+
console.log('');
255+
plutils.logOrange('While Pattern Lab may still function, assets may 404 and frontend links may break. Consider yourself warned. ');
256+
plutils.logOrange('Read More: http://patternlab.io/docs/pattern-organization.html');
257+
console.log('');
258+
}
259+
247260
//check if the found file is a top-level markdown file
248261
var fileObject = path.parse(relPath);
249262
if (fileObject.ext === '.md') {

core/lib/ui_builder.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,13 @@ var ui_builder = function () {
500500
//todo this isn't quite working yet
501501
//typePatterns = typePatterns.concat(getPatternItems(patternlab, patternType));
502502

503-
//render the viewall template
503+
//get the appropriate patternType
504+
var anyPatternOfType = _.find(typePatterns, function (pat) {
505+
return pat.patternType && pat.patternType !== '';});
506+
507+
//render the viewall template for the type
504508
var viewAllHTML = buildViewAllHTML(patternlab, typePatterns, patternType);
505-
writeFile(paths.public.patterns + p.subdir + '/index.html', mainPageHeadHtml + viewAllHTML + footerHTML);
509+
writeFile(paths.public.patterns + anyPatternOfType.patternType + '/index.html', mainPageHeadHtml + viewAllHTML + footerHTML);
506510

507511
//determine if we should omit this patterntype completely from the viewall page
508512
var omitPatternType = styleGuideExcludes && styleGuideExcludes.length

0 commit comments

Comments
 (0)