Skip to content

Commit a2062dd

Browse files
Merge pull request #1147 from pattern-lab/docs
Docs
2 parents a298bdc + 941df8a commit a2062dd

File tree

186 files changed

+8597
-34
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+8597
-34
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ If you'd like to see what a front-end project built with Pattern Lab looks like,
1616
[![node (scoped)](https://img.shields.io/node/v/@pattern-lab/patternlab-node.svg)]()
1717
[![Join the chat at Gitter](https://badges.gitter.im/pattern-lab/node.svg)](https://gitter.im/pattern-lab/node)
1818

19+
Docs @ [![Netlify Status](https://api.netlify.com/api/v1/badges/d454dbde-02c5-4bd4-8393-4ab75e862b03/deploy-status)](https://app.netlify.com/sites/patternlab-docs-preview/deploys)
20+
21+
Pattern Lab Preview @ [![Netlify Status](https://api.netlify.com/api/v1/badges/a6db1666-cb4f-4d26-82d4-9d88d875f286/deploy-status)](https://app.netlify.com/sites/patternlab-handlebars-preview/deploys)
22+
1923
## Using Pattern Lab
2024

2125
Refer to the [core usage guidelines](https://github.com/pattern-lab/patternlab-node/blob/master/packages/core/README.md#usage)

netlify.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[context.deploy-preview]
2-
command = "npm run setup && npm run preview:hbs"
2+
command = "yarn setup && yarn preview:hbs && yarn preview:docs"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"clean": "git clean -dfx",
4040
"publish": "npx lerna publish -m \"[skip travis] chore(release): publish %s\"",
4141
"postpublish": "auto release",
42+
"preview:docs": "cd packages/docs && yarn production",
4243
"preview:hbs": "cd packages/development-edition-engine-handlebars && npx patternlab add --starterkits @pattern-lab/starterkit-handlebars-vanilla && npm run pl:build"
4344
},
4445
"nyc": {

packages/docs/.eleventy.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
const rssPlugin = require('@11ty/eleventy-plugin-rss');
2+
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
3+
const eleventyNavigationPlugin = require('@11ty/eleventy-navigation');
4+
const fs = require('fs');
5+
6+
// Import filters
7+
const dateFilter = require('./src/filters/date-filter.js');
8+
const markdownFilter = require('./src/filters/markdown-filter.js');
9+
const w3DateFilter = require('./src/filters/w3-date-filter.js');
10+
11+
// Import transforms
12+
const htmlMinTransform = require('./src/transforms/html-min-transform.js');
13+
const parseTransform = require('./src/transforms/parse-transform.js');
14+
15+
// Import data files
16+
const site = require('./src/_data/site.json');
17+
18+
module.exports = function(config) {
19+
// Filters
20+
config.addFilter('dateFilter', dateFilter);
21+
config.addFilter('markdownFilter', markdownFilter);
22+
config.addFilter('w3DateFilter', w3DateFilter);
23+
24+
// Layout aliases
25+
config.addLayoutAlias('home', 'layouts/home.njk');
26+
27+
// Transforms
28+
config.addTransform('htmlmin', htmlMinTransform);
29+
config.addTransform('parse', parseTransform);
30+
31+
// Passthrough copy
32+
config.addPassthroughCopy('src/images');
33+
config.addPassthroughCopy('src/js');
34+
config.addPassthroughCopy('src/admin/config.yml');
35+
config.addPassthroughCopy('src/admin/previews.js');
36+
config.addPassthroughCopy('node_modules/nunjucks/browser/nunjucks-slim.js');
37+
38+
const now = new Date();
39+
40+
// Custom collections
41+
const livePosts = post => post.date <= now && !post.data.draft;
42+
config.addCollection('posts', collection => {
43+
return [
44+
...collection.getFilteredByGlob('./src/posts/*.md').filter(livePosts)
45+
].reverse();
46+
});
47+
48+
config.addCollection('demos', collection => {
49+
return [...collection.getFilteredByGlob('./src/demos/*.md')].reverse();
50+
});
51+
52+
config.addCollection('postFeed', collection => {
53+
return [...collection.getFilteredByGlob('./src/posts/*.md').filter(livePosts)]
54+
.reverse()
55+
.slice(0, site.maxPostsPerPage);
56+
});
57+
58+
config.addCollection('docs', collection => {
59+
return [...collection.getFilteredByGlob('./src/docs/*.md')].reverse();
60+
});
61+
62+
config.addCollection('docsOrdered', collection => {
63+
const docs = collection.getFilteredByGlob('src/docs/*.md').sort((a, b) => {
64+
return Number(a.data.order) - Number(b.data.order);
65+
});
66+
return docs;
67+
});
68+
69+
// Plugins
70+
config.addPlugin(rssPlugin);
71+
config.addPlugin(syntaxHighlight);
72+
config.addPlugin(eleventyNavigationPlugin);
73+
74+
// 404
75+
config.setBrowserSyncConfig({
76+
callbacks: {
77+
ready: function(err, browserSync) {
78+
const content_404 = fs.readFileSync('dist/404.html');
79+
80+
browserSync.addMiddleware('*', (req, res) => {
81+
// Provides the 404 content without redirect.
82+
res.write(content_404);
83+
res.end();
84+
});
85+
}
86+
}
87+
});
88+
89+
return {
90+
dir: {
91+
input: 'src',
92+
output: 'dist'
93+
},
94+
passthroughFileCopy: true
95+
};
96+
};

packages/docs/.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
*.log
2+
npm-debug.*
3+
*.scssc
4+
*.log
5+
*.swp
6+
.DS_Store
7+
.sass-cache
8+
node_modules
9+
dist
10+
11+
# Specifics
12+
13+
# Hide design tokens
14+
src/scss/_tokens.scss
15+
16+
# Hide compiled CSS
17+
src/_includes/assets/*

packages/docs/.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 90,
3+
"useTabs": true,
4+
"tabWidth": 2,
5+
"singleQuote": true,
6+
"bracketSpacing": false
7+
}

packages/docs/.vscode/launch.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Program",
11+
"skipFiles": [
12+
"<node_internals>/**"
13+
],
14+
"program": "${workspaceFolder}/index.js"
15+
}
16+
]
17+
}

packages/docs/LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 andy-bell.design and other contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/docs/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Pattern Lab Website
2+
3+
This is the website for patternlab.io. This site was build using the [Hylia starter kit](https://hylia.website/), which is a lightweight [Eleventy](https://11ty.io) starter kit.
4+
5+
---
6+
7+
## How to work with this project
8+
9+
1. Clone this repository
10+
2. `cd` into the project directory and run `yarn`
11+
3. Once all the dependencies are installed run `yarn start`
12+
4. Open your browser at `http://localhost:8080`
13+
14+
## Terminal commands
15+
16+
### Serve the site locally
17+
18+
```bash
19+
yarn start
20+
```
21+
22+
### Build a production version of the site
23+
24+
```bash
25+
yarn production
26+
```
27+
28+
### Compile Sass
29+
30+
```bash
31+
yarn sass:process
32+
```

packages/docs/package.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "patternlab-website",
3+
"version": "0.1.0",
4+
"description": "The website for patternlab.io",
5+
"main": "index.js",
6+
"dependencies": {
7+
"@11ty/eleventy": "^0.8.3",
8+
"@11ty/eleventy-plugin-rss": "^1.0.6",
9+
"@11ty/eleventy-plugin-syntaxhighlight": "^2.0.3",
10+
"@tbranyen/jsdom": "^13.0.0",
11+
"concurrently": "^4.1.0",
12+
"html-minifier": "^4.0.0",
13+
"json-to-scss": "^1.3.1",
14+
"sass": "^1.21.0",
15+
"semver": "^6.3.0",
16+
"slugify": "^1.3.4",
17+
"stalfos": "github:hankchizljaw/stalfos#c8971d22726326cfc04089b2da4d51eeb1ebb0eb"
18+
},
19+
"devDependencies": {
20+
"@11ty/eleventy-navigation": "^0.1.5",
21+
"@erquhart/rollup-plugin-node-builtins": "^2.1.5",
22+
"bl": "^3.0.0",
23+
"chokidar-cli": "^2.0.0",
24+
"cross-env": "^5.2.0",
25+
"make-dir-cli": "^2.0.0",
26+
"prettier": "^1.18.2",
27+
"rollup": "^1.16.1",
28+
"rollup-plugin-commonjs": "^10.0.0",
29+
"rollup-plugin-json": "^4.0.0",
30+
"rollup-plugin-node-resolve": "^5.0.3"
31+
},
32+
"scripts": {
33+
"sass:tokens": "npx json-to-scss src/_data/tokens.json src/scss/_tokens.scss",
34+
"sass:process": "yarn sass:tokens && sass src/scss/style.scss dist/css/style.css --style=compressed",
35+
"cms:precompile": "make-dir dist/admin && nunjucks-precompile src/_includes > dist/admin/templates.js -i \"\\.(njk|css|svg)$\"",
36+
"cms:bundle": "rollup --config",
37+
"start": "concurrently \"yarn sass:process -- --watch\" \"yarn cms:bundle -- --watch\" \"chokidar \\\"src/_includes/**\\\" -c \\\"yarn cms:precompile\\\"\" \"yarn serve\"",
38+
"serve": "cross-env ELEVENTY_ENV=development npx eleventy --serve",
39+
"production": "yarn sass:process && yarn cms:precompile && yarn cms:bundle && npx eleventy"
40+
},
41+
"repository": {
42+
"type": "git",
43+
"url": "git+https://github.com/bradfrost/pl-website-eleventy.git"
44+
},
45+
"keywords": [],
46+
"author": "",
47+
"license": "MIT",
48+
"bugs": {
49+
"url": "https://github.com/bradfrost/pl-website-eleventy/issues"
50+
},
51+
"homepage": "https://github.com/bradfrost/pl-website-eleventy/#readme"
52+
}

0 commit comments

Comments
 (0)