Skip to content

Commit 410973a

Browse files
committed
Use eleventy to generate pages
1 parent 7a9149e commit 410973a

28 files changed

+2650
-296
lines changed

.eleventy.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = (eleventyConfig) => {
2+
eleventyConfig.addPassthroughCopy('pages/scripts/index.js');
3+
eleventyConfig.addPassthroughCopy('pages/styles/protocol.css');
4+
5+
return {
6+
pathPrefix: '/devtools-protocol/',
7+
dir: {
8+
input: 'pages',
9+
output: 'devtools-protocol',
10+
data: '_data',
11+
},
12+
};
13+
};

_versions/1-2.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

_versions/1-3.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

_versions/tot.html

Lines changed: 0 additions & 11 deletions
This file was deleted.

_versions/v8.html

Lines changed: 0 additions & 7 deletions
This file was deleted.

create-search-index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
'use strict';
22

33
/**
4-
* Utility command that creates the search index for _data/?/protocol.json.
4+
* Utility command that creates the search index for pages/_data/?/protocol.json.
55
*/
66

77
const fs = require('fs');
8-
const VERSIONS_FILE = '_data/versions.json';
8+
const VERSIONS_FILE = 'pages/_data/versions.json';
99

1010
const versionsText = fs.readFileSync(VERSIONS_FILE);
1111
const versions = JSON.parse(versionsText);
1212

1313
versions.forEach(generateSearchIndex);
1414

1515
function generateSearchIndex(version) {
16-
const protocolText = fs.readFileSync(`_data/${version.slug}/protocol.json`);
16+
const protocolText = fs.readFileSync(`pages/_data/${version.slug}/protocol.json`);
1717
const protocol = JSON.parse(protocolText);
1818

1919
// Set up Keyword bank

elements/cr-domain/cr-domain.js

Lines changed: 3 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import './cr-domain-experimental.js';
44
import './cr-domain-toc.js';
55
import './cr-domain-details.js';
66

7+
import {domainTemplate} from './cr-domain.template.js';
8+
79
export class ChromeDevToolsDomain extends PolymerElement {
810
static get properties() {
911
return {
@@ -16,109 +18,7 @@ export class ChromeDevToolsDomain extends PolymerElement {
1618
}
1719
}
1820
static get template() {
19-
return html`
20-
<style>
21-
h3 {
22-
font-size: 20px;
23-
line-height: 28px;
24-
}
25-
26-
/* Small */
27-
@media (max-width: 600px) {
28-
h3 {
29-
margin-left: 7px;
30-
}
31-
}
32-
</style>
33-
<div id="header">
34-
<div class="paper-material" elevation="1" class="heading-domain">
35-
<h2 class="heading"><span>[[domain.domain]]</span> Domain</h2>
36-
37-
<p class="description" hidden$="[[!domain.description]]">
38-
<cr-markdownish markdown="[[domain.description]]"></cr-markdownish>
39-
</p>
40-
<cr-domain-experimental item="[[domain]]"></cr-domain-experimental>
41-
42-
<div hidden$="[[!domain.commands.length]]">
43-
<h3>Methods</h3>
44-
<template is="dom-repeat" items="[[domain.commands]]">
45-
<cr-domain-toc
46-
domain="[[domain.domain]]"
47-
details="[[item]]"
48-
version="[[version]]"
49-
type="method"
50-
></cr-domain-toc>
51-
</template>
52-
</div>
53-
54-
<div hidden$="[[!domain.events.length]]">
55-
<h3>Events</h3>
56-
<template is="dom-repeat" items="[[domain.events]]">
57-
<cr-domain-toc
58-
domain="[[domain.domain]]"
59-
details="[[item]]"
60-
version="[[version]]"
61-
type="event"
62-
></cr-domain-toc>
63-
</template>
64-
</div>
65-
66-
<div hidden$="[[!domain.types.length]]">
67-
<h3>Types</h3>
68-
<template is="dom-repeat" items="[[domain.types]]">
69-
<cr-domain-toc
70-
domain="[[domain.domain]]"
71-
details="[[item]]"
72-
version="[[version]]"
73-
type="type"
74-
></cr-domain-toc>
75-
</template>
76-
</div>
77-
78-
</div>
79-
80-
<div hidden$="[[!domain.commands.length]]">
81-
<h3 id="methods">Methods</h3>
82-
<div class="paper-material" elevation="1">
83-
<template is="dom-repeat" items="[[domain.commands]]">
84-
<cr-domain-details
85-
domain="[[domain.domain]]"
86-
details="[[item]]"
87-
version="[[version]]"
88-
type="method"
89-
></cr-domain-details>
90-
</template>
91-
</div>
92-
</div>
93-
94-
<div hidden$="[[!domain.events.length]]">
95-
<h3 id="events">Events</h3>
96-
<div class="paper-material" elevation="1">
97-
<template is="dom-repeat" items="[[domain.events]]">
98-
<cr-domain-details
99-
domain="[[domain.domain]]"
100-
details="[[item]]"
101-
version="[[version]]"
102-
type="event"
103-
></cr-domain-details>
104-
</template>
105-
</div>
106-
</div>
107-
108-
<div hidden$="[[!domain.types.length]]">
109-
<h3 id="types">Types</h3>
110-
<div class="paper-material" elevation="1">
111-
<template is="dom-repeat" items="[[domain.types]]">
112-
<cr-domain-details
113-
domain="[[domain.domain]]"
114-
details="[[item]]"
115-
version="[[version]]"
116-
type="type"
117-
></cr-domain-details>
118-
</template>
119-
</div>
120-
</div>
121-
</div>`;
21+
return domainTemplate({});
12222
}
12323
_domainChanged(newDomain) {
12424
if (newDomain.experimental) {
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import {html} from '../../node_modules/lit-html/lit-html.js';
2+
3+
export const domainTemplate = (domain) => html`
4+
<style>
5+
h3 {
6+
font-size: 20px;
7+
line-height: 28px;
8+
}
9+
10+
/* Small */
11+
@media (max-width: 600px) {
12+
h3 {
13+
margin-left: 7px;
14+
}
15+
}
16+
</style>
17+
<div id="header">
18+
<div class="paper-material" elevation="1" class="heading-domain">
19+
<h2 class="heading"><span>[[domain.domain]]</span> Domain</h2>
20+
21+
<p class="description" hidden$="[[!domain.description]]">
22+
<cr-markdownish markdown="[[domain.description]]"></cr-markdownish>
23+
</p>
24+
<cr-domain-experimental item="[[domain]]"></cr-domain-experimental>
25+
26+
${
27+
domain.domain
28+
}
29+
30+
<div hidden$="[[!domain.commands.length]]">
31+
<h3>Methods</h3>
32+
<template is="dom-repeat" items="[[domain.commands]]">
33+
<cr-domain-toc
34+
domain="[[domain.domain]]"
35+
details="[[item]]"
36+
version="[[version]]"
37+
type="method"
38+
></cr-domain-toc>
39+
</template>
40+
</div>
41+
42+
<div hidden$="[[!domain.events.length]]">
43+
<h3>Events</h3>
44+
<template is="dom-repeat" items="[[domain.events]]">
45+
<cr-domain-toc
46+
domain="[[domain.domain]]"
47+
details="[[item]]"
48+
version="[[version]]"
49+
type="event"
50+
></cr-domain-toc>
51+
</template>
52+
</div>
53+
54+
<div hidden$="[[!domain.types.length]]">
55+
<h3>Types</h3>
56+
<template is="dom-repeat" items="[[domain.types]]">
57+
<cr-domain-toc
58+
domain="[[domain.domain]]"
59+
details="[[item]]"
60+
version="[[version]]"
61+
type="type"
62+
></cr-domain-toc>
63+
</template>
64+
</div>
65+
66+
</div>
67+
68+
<div hidden$="[[!domain.commands.length]]">
69+
<h3 id="methods">Methods</h3>
70+
<div class="paper-material" elevation="1">
71+
<template is="dom-repeat" items="[[domain.commands]]">
72+
<cr-domain-details
73+
domain="[[domain.domain]]"
74+
details="[[item]]"
75+
version="[[version]]"
76+
type="method"
77+
></cr-domain-details>
78+
</template>
79+
</div>
80+
</div>
81+
82+
<div hidden$="[[!domain.events.length]]">
83+
<h3 id="events">Events</h3>
84+
<div class="paper-material" elevation="1">
85+
<template is="dom-repeat" items="[[domain.events]]">
86+
<cr-domain-details
87+
domain="[[domain.domain]]"
88+
details="[[item]]"
89+
version="[[version]]"
90+
type="event"
91+
></cr-domain-details>
92+
</template>
93+
</div>
94+
</div>
95+
96+
<div hidden$="[[!domain.types.length]]">
97+
<h3 id="types">Types</h3>
98+
<div class="paper-material" elevation="1">
99+
<template is="dom-repeat" items="[[domain.types]]">
100+
<cr-domain-details
101+
domain="[[domain.domain]]"
102+
details="[[item]]"
103+
version="[[version]]"
104+
type="type"
105+
></cr-domain-details>
106+
</template>
107+
</div>
108+
</div>
109+
</div>`;

generate-sidenav-html.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict';
22

33

4-
const verSlugs = require('./_data/versions.json').map(e => e.slug);
4+
const verSlugs = require('./pages/_data/versions.json').map(e => e.slug);
55

66
const allDomains = {};
77

88
for (const slug of verSlugs){
9-
const protocol = require(`./_data/${slug}/protocol.json`);
9+
const protocol = require(`./pages/_data/${slug}/protocol.json`);
1010
const domains = protocol.domains;
1111
domains.forEach(domain => {
1212
const id = domain.domain;

make-stable-protocol.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
const fs = require('fs');
8-
const tot = JSON.parse(fs.readFileSync(__dirname + '/_data/tot/protocol.json', 'utf8'));
8+
const tot = JSON.parse(fs.readFileSync(__dirname + '/pages/_data/tot.json', 'utf8'));
99

1010

1111
const isNotExperimentalOrDeprecated = item => !item.experimental && !item.deprecated;
@@ -26,5 +26,5 @@ stableProtocol.domains.forEach(domain => {
2626
});
2727

2828
// filter out command params, too?
29-
fs.writeFileSync(__dirname + '/_data/1-3/protocol.json', JSON.stringify(stableProtocol, null, 2));
29+
fs.writeFileSync(__dirname + '/pages/_data/1-3.json', JSON.stringify(stableProtocol, null, 2));
3030

0 commit comments

Comments
 (0)