Skip to content

Commit 1f8a1ec

Browse files
committed
Initial commit. Partial migration.
1 parent 1ec4bb1 commit 1f8a1ec

File tree

294 files changed

+23392
-9540
lines changed

Some content is hidden

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

294 files changed

+23392
-9540
lines changed

.eleventy.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const path = require('path');
2+
const pluginSyntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
3+
const helpers = require('./templateHelpers');
4+
5+
module.exports = function(eleventyConfig) {
6+
// Syntax highlighting for code snippets
7+
eleventyConfig.addPlugin(pluginSyntaxHighlight);
8+
9+
// TODO: Add RSS plugin
10+
// https://github.com/11ty/eleventy-plugin-rss
11+
12+
// Return the three most recent blog posts.
13+
eleventyConfig.addCollection('recentPosts', function(collection) {
14+
return collection
15+
.getFilteredByTag('post')
16+
.reverse()
17+
.slice(0, 3);
18+
});
19+
20+
eleventyConfig.addFilter('stripLanguage', function(url) {
21+
let urlParts = url.split('/');
22+
urlParts.splice(1, 1);
23+
return urlParts.join('/');
24+
});
25+
26+
eleventyConfig.addShortcode('getGuidesCount', function(learningPath) {
27+
const count = learningPath.topics.reduce((guidesCount, topic) => {
28+
return guidesCount + topic.guides.length;
29+
}, 0);
30+
const label = count > 1 ? 'resources' : 'resource';
31+
return `${count} ${label}`;
32+
});
33+
34+
eleventyConfig.addShortcode('nextGuideLink', function(page, paths) {
35+
const collection = helpers.getCollectionName(page);
36+
if (collection && paths[collection]) {
37+
const guides = helpers.getGuidesFromTopics(paths[collection].topics);
38+
const nextIndex = guides.indexOf(page.fileSlug) + 1;
39+
if (nextIndex && nextIndex < guides.length) {
40+
const nextUrl = `/${paths[collection].basePath}${guides[nextIndex]}/`;
41+
return nextUrl;
42+
}
43+
return '';
44+
}
45+
});
46+
47+
eleventyConfig.addFilter('containsTag', function(article, tags) {
48+
return article.data.tags && tags.filter(tag => article.data.tags.indexOf(tag) > -1).length > 0;
49+
});
50+
51+
// https://www.11ty.io/docs/config/#configuration-options
52+
return {
53+
dir: {
54+
input: 'src/site/content',
55+
output: 'dist',
56+
data: '../_data',
57+
includes: '../_includes',
58+
},
59+
templateFormats: ['njk', 'md'],
60+
htmlTemplateEngine: 'njk',
61+
markdownTemplateEngine: 'njk',
62+
// Because eleventy's passthroughFileCopy does not work with permalinks
63+
// we need to manually copy assets ourselves using gulp.
64+
// https://github.com/11ty/eleventy/issues/379
65+
passthroughFileCopy: false,
66+
};
67+
};

.eslintrc

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
{
2-
"plugins": ["prettier"],
3-
"extends": ["eslint:recommended", "google"],
2+
"plugins": [
3+
"prettier"
4+
],
5+
"extends": [
6+
"eslint:recommended",
7+
"google"
8+
],
49
"rules": {
5-
"indent": ["error", 2, {
10+
"indent": [
11+
"error",
12+
2,
13+
{
614
"SwitchCase": 1
7-
}]
15+
}
16+
]
817
},
918
"env": {
1019
"es6": true,
1120
"node": true,
12-
"mocha": true
21+
"mocha": true,
22+
"browser": true
1323
},
1424
"parserOptions": {
15-
"ecmaVersion": 2017
25+
"ecmaVersion": 2017,
26+
"sourceType": "module"
27+
},
28+
"globals": {
29+
"customElements": true
1630
}
17-
}
31+
}

.gitignore

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,68 @@
1-
.DS_Store
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
236
node_modules/
3-
build/
4-
package-lock.json
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
558
.env
59+
60+
# next.js build output
61+
.next
62+
63+
# build artifacts
64+
dist
65+
66+
# deploy scripts
67+
devsite.js
68+
local-devsite.js

.sasslintrc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"options": {
3+
"merge-default-rules": false
4+
},
5+
"files": {
6+
"ignore": [
7+
"src/styles/devsite/**/*.scss",
8+
"src/styles/tools/**/*.scss"
9+
]
10+
},
11+
"rules": {
12+
"attribute-quotes": 1,
13+
"brace-style": [
14+
1,
15+
{
16+
"style": "1tbs"
17+
}
18+
],
19+
"border-zero": [
20+
1,
21+
{
22+
"convention": "0"
23+
}
24+
],
25+
"class-name-format": [
26+
1,
27+
{
28+
"convention": "^w-.+",
29+
"convention-explanation": "Classes must be namedspaced with w-* prefix."
30+
}
31+
],
32+
"declarations-before-nesting": 1,
33+
"no-debug": 1,
34+
"no-css-comments": 1,
35+
"property-sort-order": [
36+
1,
37+
{
38+
"order": "alphabetical"
39+
}
40+
],
41+
"variable-name-format": [
42+
1,
43+
{
44+
"convention": "^[_A-Z0-9]+$",
45+
"convention-explanation": "Variable names should be in $SCREAMING_SNAKE_CASE"
46+
}
47+
]
48+
}
49+
}

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ cache:
1111
script:
1212
- npm run lint
1313
- npm run build
14-
- npm run test

README.md

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,75 @@
22

33
[![Build Status](https://travis-ci.org/GoogleChrome/web.dev.svg?branch=master)](https://travis-ci.org/GoogleChrome/web.dev)
44

5-
web.dev is the ultimate resource for developers of all backgrounds to learn, create, and solve on the web. It's meant to not only educate developers, but help them apply what they've learned to any site they work on, be it personal or business.
5+
web.dev is the ultimate resource for developers of all backgrounds to learn,
6+
create, and solve on the web. It's meant to not only educate developers, but
7+
help them apply what they've learned to any site they work on, be it personal or
8+
business.
69

7-
Note: this repo contains the written content for web.dev. The actual front-end
8-
(CSS,JS) is not yet open source.
10+
Note: this repo contains the written content for web.dev. The client-side JS and
11+
server are not yet open source.
912

1013
## Authoring content
1114

12-
[Our wiki](https://github.com/GoogleChrome/web.dev/wiki) provides docs on authoring guides and codelabs.
15+
[Our wiki](https://github.com/GoogleChrome/web.dev/wiki) provides docs on
16+
authoring guides and codelabs.
1317

14-
## Development
18+
## Get started
1519

16-
```shell
17-
git clone https://github.com/GoogleChrome/web.dev.git
20+
Install dependencies.
21+
22+
```
23+
npm ci
1824
```
1925

20-
Install the deps:
26+
Compile docs into the `dist` directory.
2127

22-
```shell
23-
yarn
28+
```
29+
npm run build
2430
```
2531

26-
### Previewing the site
27-
28-
To create/edit content and preview a page locally as you make edits, start the "preview server":
32+
Start a local server to preview the site. Changes to assets will rebuild
33+
the site. Refresh to see changes.
2934

30-
```shell
31-
yarn dev
3235
```
33-
34-
This also runs `gulp watch` which rebuild pages as you make edits.
36+
npm run dev
37+
```
3538

3639
Next, open `http://localhost:8080/` to see the site locally. The preview server
3740
allows you to see how the content will look on the production site, but it's
3841
not a true staging server. For example, features like search and JS components
3942
may not work or be entirely broken on the local preview.
4043

41-
### Running the tests
44+
## Debugging
4245

43-
The preview server has tests to verify that pages render locally.
46+
The easiest way to debug the site is to add a `debugger` statement to
47+
`.eleventy.js`, then run `npm run debug`, and go to `chrome://inspect` to
48+
attach to the running process.
4449

45-
```shell
46-
yarn test
47-
```
50+
## Creating templates
51+
52+
### Includes vs. macros
53+
54+
[includes](https://mozilla.github.io/nunjucks/templating.html#include)
55+
have access to the global data objects created by eleventy's `_data` folder and
56+
have access to the scope of their including template.
57+
58+
[macros](https://mozilla.github.io/nunjucks/templating.html#macro) define their
59+
own scope and must have all data passed in as arguments.
60+
61+
Whenever possible, **use macros instead of includes**. Explicitly passing data
62+
to a function is preferred over relying on global state. This avoids situations
63+
where the global object is accidentally renamed without updating the dependent
64+
templates.
4865

4966
## Found a bug?
5067

51-
You can file an issue [in our issue tracker](https://github.com/GoogleChrome/web.dev/issues) and a team member should reply shortly.
68+
You can file an issue [in our issue
69+
tracker](https://github.com/GoogleChrome/web.dev/issues) and a team member
70+
should reply shortly.
5271

5372
## Want to help?
5473

55-
Take a look [in the issue tracker](https://github.com/GoogleChrome/web.dev/issues) for any bugs with a **content** label.
74+
Take a look [in the issue
75+
tracker](https://github.com/GoogleChrome/web.dev/issues) for any bugs with a
76+
**content** label.

0 commit comments

Comments
 (0)