Skip to content

Commit 7560c04

Browse files
bradfrostbmuenzenmeyer
authored andcommitted
Add ordered subnav
1 parent 0d5fb07 commit 7560c04

File tree

6 files changed

+104
-98
lines changed

6 files changed

+104
-98
lines changed

packages/docs/.eleventy.js

Lines changed: 75 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -15,75 +15,80 @@ const parseTransform = require('./src/transforms/parse-transform.js');
1515
const site = require('./src/_data/site.json');
1616

1717
module.exports = function(config) {
18-
// Filters
19-
config.addFilter('dateFilter', dateFilter);
20-
config.addFilter('markdownFilter', markdownFilter);
21-
config.addFilter('w3DateFilter', w3DateFilter);
22-
23-
// Layout aliases
24-
config.addLayoutAlias('home', 'layouts/home.njk');
25-
26-
// Transforms
27-
config.addTransform('htmlmin', htmlMinTransform);
28-
config.addTransform('parse', parseTransform);
29-
30-
// Passthrough copy
31-
config.addPassthroughCopy('src/images');
32-
config.addPassthroughCopy('src/js');
33-
config.addPassthroughCopy('src/admin/config.yml');
34-
config.addPassthroughCopy('src/admin/previews.js');
35-
config.addPassthroughCopy('node_modules/nunjucks/browser/nunjucks-slim.js');
36-
37-
const now = new Date();
38-
39-
// Custom collections
40-
const livePosts = post => post.date <= now && !post.data.draft;
41-
config.addCollection('posts', collection => {
42-
return [
43-
...collection.getFilteredByGlob('./src/posts/*.md').filter(livePosts)
44-
].reverse();
45-
});
46-
47-
config.addCollection('demos', collection => {
48-
return [
49-
...collection.getFilteredByGlob('./src/demos/*.md')
50-
].reverse();
51-
});
52-
53-
config.addCollection('postFeed', collection => {
54-
return [...collection.getFilteredByGlob('./src/posts/*.md').filter(livePosts)]
55-
.reverse()
56-
.slice(0, site.maxPostsPerPage);
57-
});
58-
59-
config.addCollection('docs', collection => {
60-
return [...collection.getFilteredByGlob('./src/docs/*.md')].reverse();
61-
});
62-
63-
// Plugins
64-
config.addPlugin(rssPlugin);
65-
config.addPlugin(syntaxHighlight);
66-
67-
// 404
68-
config.setBrowserSyncConfig({
69-
callbacks: {
70-
ready: function(err, browserSync) {
71-
const content_404 = fs.readFileSync('dist/404.html');
72-
73-
browserSync.addMiddleware('*', (req, res) => {
74-
// Provides the 404 content without redirect.
75-
res.write(content_404);
76-
res.end();
18+
// Filters
19+
config.addFilter('dateFilter', dateFilter);
20+
config.addFilter('markdownFilter', markdownFilter);
21+
config.addFilter('w3DateFilter', w3DateFilter);
22+
23+
// Layout aliases
24+
config.addLayoutAlias('home', 'layouts/home.njk');
25+
26+
// Transforms
27+
config.addTransform('htmlmin', htmlMinTransform);
28+
config.addTransform('parse', parseTransform);
29+
30+
// Passthrough copy
31+
config.addPassthroughCopy('src/images');
32+
config.addPassthroughCopy('src/js');
33+
config.addPassthroughCopy('src/admin/config.yml');
34+
config.addPassthroughCopy('src/admin/previews.js');
35+
config.addPassthroughCopy('node_modules/nunjucks/browser/nunjucks-slim.js');
36+
37+
const now = new Date();
38+
39+
// Custom collections
40+
const livePosts = post => post.date <= now && !post.data.draft;
41+
config.addCollection('posts', collection => {
42+
return [
43+
...collection.getFilteredByGlob('./src/posts/*.md').filter(livePosts)
44+
].reverse();
45+
});
46+
47+
config.addCollection('demos', collection => {
48+
return [...collection.getFilteredByGlob('./src/demos/*.md')].reverse();
49+
});
50+
51+
config.addCollection('postFeed', collection => {
52+
return [...collection.getFilteredByGlob('./src/posts/*.md').filter(livePosts)]
53+
.reverse()
54+
.slice(0, site.maxPostsPerPage);
55+
});
56+
57+
config.addCollection('docs', collection => {
58+
return [...collection.getFilteredByGlob('./src/docs/*.md')].reverse();
59+
});
60+
61+
config.addCollection('docsOrdered', collection => {
62+
const docs = collection.getFilteredByGlob('src/docs/*.md').sort((a, b) => {
63+
return Number(a.data.order) - Number(b.data.order);
7764
});
78-
}
79-
}
80-
});
81-
82-
return {
83-
dir: {
84-
input: 'src',
85-
output: 'dist'
86-
},
87-
passthroughFileCopy: true
88-
};
65+
return docs;
66+
});
67+
68+
// Plugins
69+
config.addPlugin(rssPlugin);
70+
config.addPlugin(syntaxHighlight);
71+
72+
// 404
73+
config.setBrowserSyncConfig({
74+
callbacks: {
75+
ready: function(err, browserSync) {
76+
const content_404 = fs.readFileSync('dist/404.html');
77+
78+
browserSync.addMiddleware('*', (req, res) => {
79+
// Provides the 404 content without redirect.
80+
res.write(content_404);
81+
res.end();
82+
});
83+
}
84+
}
85+
});
86+
87+
return {
88+
dir: {
89+
input: 'src',
90+
output: 'dist'
91+
},
92+
passthroughFileCopy: true
93+
};
8994
};

packages/docs/src/_includes/components/tree-subnav.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ul class="c-tree-nav__subnav">
2-
{% for doc in collections.docs %}
2+
{% for doc in collections.docsOrdered %}
33
{% if doc.data.category == subnavCategory %}
44
<li class="c-tree-nav__subnav-item">
55
<a href="{{doc.url}}" class="c-tree-nav__subnav-link">

packages/docs/src/docs/advanced-config-options.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
title: Editing the Configuration Options
33
tags:
4-
- docs
4+
- docs
55
category: getting-started
6+
order: 50
67
---
78

89
Pattern Lab Node comes with a configuration file [(`patternlab-config.json`)](https://github.com/pattern-lab/patternlab-node/blob/master/packages/core/patternlab-config.json) that allows you to modify certain aspects of the system. The latest default values are included within. This file is shipped within [the editions](https://github.com/pattern-lab?utf8=%E2%9C%93&query=edition-node) or can be supplied from core and the command line interface. Below is a description of each configuration option and how it affects Pattern Lab Node.
@@ -85,11 +86,11 @@ Sets the boundaries of each of the viewport toggles, 'S'mall, 'M'edium, and 'L'a
8586

8687
Sets the level of verbosity for Pattern Lab Node logging.
8788

88-
- `error` will output a message as a thrown error
89-
- `warning` will output all warnings plus above
90-
- `info` will output all info messages, plus above (intended default)
91-
- `debug` will output all debug messages, plus above
92-
- `quiet` will output ZERO logs
89+
- `error` will output a message as a thrown error
90+
- `warning` will output all warnings plus above
91+
- `info` will output all info messages, plus above (intended default)
92+
- `debug` will output all debug messages, plus above
93+
- `quiet` will output ZERO logs
9394

9495
This replaces the now obsolete `debug` flag.
9596

@@ -251,8 +252,8 @@ Introduced in Pattern Lab Node v3, UIKits are a new term in the Pattern Lab [Eco
251252

252253
`uikits` accepts an array of UIKit objects, shipping with the one above.
253254

254-
- `name`: the name of the UIKit
255-
- `outputDir` where to output this UIKit relative to the current root. By leaving this empty we retain the existing Pattern Lab 2.X behavior, outputting to `<project_root>/public`. If you had multiple UIKits, however, you would provide different values, such as:
255+
- `name`: the name of the UIKit
256+
- `outputDir` where to output this UIKit relative to the current root. By leaving this empty we retain the existing Pattern Lab 2.X behavior, outputting to `<project_root>/public`. If you had multiple UIKits, however, you would provide different values, such as:
256257

257258
```javascript
258259
"uikits": [
@@ -269,16 +270,16 @@ Introduced in Pattern Lab Node v3, UIKits are a new term in the Pattern Lab [Eco
269270
]
270271
```
271272

272-
- `enabled`: quickly turn on or off the building of this UIKit
273-
- `excludedPatternStates`: tell Pattern Lab not to include patterns with these states in this UIKit's output
274-
- `excludedPatternTags`: tell Pattern Lab not to include patterns with these tags in this UIKit's output
275-
- [currently not supported](https://github.com/pattern-lab/patternlab-node/issues/844)
273+
- `enabled`: quickly turn on or off the building of this UIKit
274+
- `excludedPatternStates`: tell Pattern Lab not to include patterns with these states in this UIKit's output
275+
- `excludedPatternTags`: tell Pattern Lab not to include patterns with these tags in this UIKit's output
276+
- [currently not supported](https://github.com/pattern-lab/patternlab-node/issues/844)
276277

277278
Important details:
278279

279-
- the [default `paths.source` object paths](https://github.com/pattern-lab/patternlab-node/pull/840/commits/a4961bd5d696a05fb516cdd951163b0f918d5e19) within `patternlab-config.json` are now relative to the current UIKit. See the [structure of uikit-workshop](https://github.com/pattern-lab/patternlab-node/tree/master/packages/uikit-workshop) for more info
280-
- the [default `paths.public` object paths](https://github.com/pattern-lab/patternlab-node/pull/840/commits/812bab3659f504043e8b61b1dc1cdac71f248449) within `patternlab-config.json` are now relative to the current UIKit's `outputDir`. Absolute paths will no longer work. Someone could test putting an absolute path in a UIKit `outputDir` property and see what happens I suppose.
281-
- `dependencyGraph.json` has moved to the project root rather than `public/` as we should only retain one
280+
- the [default `paths.source` object paths](https://github.com/pattern-lab/patternlab-node/pull/840/commits/a4961bd5d696a05fb516cdd951163b0f918d5e19) within `patternlab-config.json` are now relative to the current UIKit. See the [structure of uikit-workshop](https://github.com/pattern-lab/patternlab-node/tree/master/packages/uikit-workshop) for more info
281+
- the [default `paths.public` object paths](https://github.com/pattern-lab/patternlab-node/pull/840/commits/812bab3659f504043e8b61b1dc1cdac71f248449) within `patternlab-config.json` are now relative to the current UIKit's `outputDir`. Absolute paths will no longer work. Someone could test putting an absolute path in a UIKit `outputDir` property and see what happens I suppose.
282+
- `dependencyGraph.json` has moved to the project root rather than `public/` as we should only retain one
282283

283284
**default**:
284285

@@ -293,4 +294,3 @@ Important details:
293294
}
294295
]
295296
```
296-

packages/docs/src/docs/editing-source-files.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
title: Editing Pattern Lab Source Files
33
tags:
4-
- docs
4+
- docs
55
category: getting-started
6+
order: 20
67
---
78

89
When editing Pattern Lab you must put your files and edit them in the `./source/` directory. This includes your static assets like [JavaScript, CSS, and images](/docs/pattern-managing-assets.html). Each time [your site is generated](/docs/generating-pattern-lab.html) your patterns will be compiled and your static assets will be moved to the `./public/` directory. Because of this you **should not edit** the files in the `./public/` directory.
@@ -11,10 +12,10 @@ When editing Pattern Lab you must put your files and edit them in the `./source/
1112

1213
For the most part you can organize `./source/` anyway you see fit. There are a few Pattern Lab-specific directories though. They are:
1314

14-
- `_annotations/` - where your annotations reside. [learn more](/docs/pattern-adding-annotations.html).
15-
- `_data/` - where the global data used to render your patterns resides. [learn more](/docs/data-overview.html).
16-
- `_meta/` - where the header and footer that get applied to all of your patterns resides. [learn more](/docs/pattern-header-footer.html).
17-
- `_patterns/` - where your patterns, pattern documentation, and pattern-specific data reside. [learn more](/docs/pattern-organization.html).
15+
- `_annotations/` - where your annotations reside. [learn more](/docs/pattern-adding-annotations.html).
16+
- `_data/` - where the global data used to render your patterns resides. [learn more](/docs/data-overview.html).
17+
- `_meta/` - where the header and footer that get applied to all of your patterns resides. [learn more](/docs/pattern-header-footer.html).
18+
- `_patterns/` - where your patterns, pattern documentation, and pattern-specific data reside. [learn more](/docs/pattern-organization.html).
1819

1920
## Configuring Pattern Lab Directories
2021

packages/docs/src/docs/generating-pattern-lab.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
title: Generating Pattern Lab
33
tags:
4-
- docs
4+
- docs
55
category: getting-started
6+
order: 10
67
---
78

89
Running Pattern Lab for the first time will vary depending on which version was [installed](/docs/installation.html).
@@ -45,5 +46,3 @@ To stop watching and serving files on Mac OS X and Windows you can press`CTRL+C`
4546
## Pattern Lab is now running: now what?
4647

4748
Your Pattern Lab should now be populated and [available for viewing](/docs/viewing-patterns.html#node) and you can [make changes to your patterns](/docs/editing-source-files.html).
48-
49-

packages/docs/src/docs/installation.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
title: Installing Pattern Lab
33
tags:
4-
- docs
4+
- docs
55
category: getting-started
6+
order: 0
67
---
78

89
## Step 1: Install Requirements
@@ -29,8 +30,8 @@ This will bring up an installation menu that presents the following steps:
2930

3031
!["choose edition"](/images/3chooseedition.png)
3132

32-
- `edition-node (handlebars engine)`
33-
- `edition-node-gulp (legacy)`
33+
- `edition-node (handlebars engine)`
34+
- `edition-node-gulp (legacy)`
3435

3536
3. `Which starterkit do you want to use?` - Choose the <a href="/docs/advanced-starterkits.html">Starterkit</a> you want to begin your project with. Starterkits define the initial components and assets that are included in the initial project. Start from scratch, start from a full demo, or a lightweight boilerplate.
3637

0 commit comments

Comments
 (0)