Skip to content

Commit 6f967dc

Browse files
committed
Merge branch 'geoffp-default-pattern-config' into dev
2 parents 88198f0 + 848a29f commit 6f967dc

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,18 @@ Coupled with exported css (much easier to extract with existing tools like [grun
173173

174174
Default: true
175175

176+
##### defaultPattter
177+
`config.json` has an entry that allows you to specifiy a specific pattern upon launch of the main site. It works even without BrowserSync running. Set it like this:
178+
179+
```
180+
"defaultPattern": "pages-homepage",
181+
```
182+
Default: "all"
183+
If running with BrowserSync, you may also set [this BrowserSync options](https://www.browsersync.io/docs/options/#option-startPath) to achieve the same result via your Gruntfile or Gulpfile.
184+
185+
```
186+
startPath: '/?p=pages-homepage',
187+
```
176188

177189
##### baseurl
178190

config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"templates",
2727
"pages"
2828
],
29+
"defaultPattern": "all",
2930
"ignored-extensions" : ["scss", "DS_Store", "less"],
3031
"ignored-directories" : ["scss"],
3132
"debug": false,

core/lib/patternlab.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,10 @@ var patternlab_engine = function (config) {
543543
var viewAllPathsPartialHtml = pattern_assembler.renderPattern(viewAllPathsTemplate, {'viewallpaths': JSON.stringify(patternlab.viewAllPaths)});
544544

545545
//render the patternlab template, with all partials
546-
var patternlabSiteHtml = pattern_assembler.renderPattern(patternlabSiteTemplate, {cacheBuster: patternlab.cacheBuster}, {
546+
var patternlabSiteHtml = pattern_assembler.renderPattern(patternlabSiteTemplate, {
547+
defaultPattern: patternlab.config.defaultPattern || 'all',
548+
cacheBuster: patternlab.cacheBuster
549+
}, {
547550
'ishControls': ishControlsPartialHtml,
548551
'patternNav': patternNavPartialHtml,
549552
'patternPaths': patternPathsPartialHtml,

core/styleguide/js/styleguide.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,16 +469,18 @@
469469
}
470470

471471
// load the iframe source
472-
var patternName = "all";
472+
var patternName = window.defaultPattern || "all";
473473
var patternPath = "";
474-
var iFramePath = window.location.protocol+"//"+window.location.host+window.location.pathname.replace("index.html","")+"styleguide/html/styleguide.html";
474+
var iFramePath = window.location.protocol + "//" + window.location.host + window.location.pathname.replace("index.html","") + "styleguide/html/styleguide.html";
475+
476+
// if we were passed some url parameters, deal with it
475477
if ((oGetVars.p != undefined) || (oGetVars.pattern != undefined)) {
476478
patternName = (oGetVars.p != undefined) ? oGetVars.p : oGetVars.pattern;
477-
patternPath = urlHandler.getFileName(patternName);
478-
iFramePath = (patternPath != "") ? window.location.protocol+"//"+window.location.host+window.location.pathname.replace("index.html","")+patternPath : iFramePath;
479479
}
480480

481481
if (patternName != "all") {
482+
patternPath = urlHandler.getFileName(patternName);
483+
iFramePath = (patternPath != "") ? window.location.protocol + "//" + window.location.host + window.location.pathname.replace("index.html","") + patternPath : iFramePath;
482484
document.getElementById("title").innerHTML = "Pattern Lab - "+patternName;
483485
history.replaceState({ "pattern": patternName }, null, null);
484486
}

core/templates/index.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<link rel="stylesheet" href="styleguide/css/vendor/prism.css?{{ cacheBuster }}" media="all" />
1919
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
2020
<script>window.jQuery || document.write('<script src="styleguide/js/vendor/jquery.js"><\/script>')</script>
21+
<script>window.defaultPattern = '{{defaultPattern}}';</script>
2122
</head>
2223
<body id="patternlab-body">>
2324
<!--Style Guide Header-->

0 commit comments

Comments
 (0)