Skip to content

Commit 96773d8

Browse files
committed
fix: add technology script
Create the files in the right place after flattening the docs folder.
1 parent 5f7e725 commit 96773d8

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

scripts/add-technology.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,18 @@ const TECHNOLOGY = {
3232
JavaScript: '',
3333
Rust: '',
3434
},
35-
releases: [{
36-
version: '0.0.1',
37-
date: '2021-01-01T00:00:00Z'
38-
}],
35+
releases: [
36+
{
37+
version: '0.0.1',
38+
date: '2021-01-01T00:00:00Z',
39+
},
40+
],
3941
url: 'https://',
4042
community: 'https://',
4143
documentation: 'https://',
4244
};
4345

44-
const categories = [
45-
'Browser engine',
46-
'Compiled',
47-
'JavaScript projection',
48-
'Web',
49-
];
46+
const categories = ['Browser engine', 'Direct drawing', 'Platform controls'];
5047

5148
/**
5249
* Listens for stdin and returns the first line of text received.
@@ -143,7 +140,9 @@ const writeTemplates = async (templates, information, destination) => {
143140

144141
for (const [filePath, content] of templates) {
145142
// 🛑 HACK ahead!! we assume that `information[1]` is `normalizedTechnology`. We should probably validate this
146-
const finalPath = path.join(destination, filePath).replace('technology', information[1].value);
143+
const finalPath = path
144+
.join(destination, filePath)
145+
.replace('technology', information[1].value);
147146

148147
const interpolatedContent = interpolate(content, information);
149148

@@ -189,31 +188,29 @@ ${categories.join('\n')}`);
189188
},
190189
];
191190

192-
const createdFiles = await writeTemplates(
193-
templates,
194-
information,
195-
path.join(DOCS_ROOT, normalizedCategory)
196-
);
191+
const createdFiles = await writeTemplates(templates, information, DOCS_ROOT);
197192

198193
console.log(`Documentation files created:
199194
${createdFiles.join('\n')}`);
200195

201196
const json = { ...TECHNOLOGY, ...{ name: technology } };
202197

203198
await fs.writeFile(
204-
path.join(DATA_PATH, `${normalizedTechnology}.json`),
199+
path.join(DATA_PATH, 'technologies', `${normalizedTechnology}.json`),
205200
JSON.stringify(json, null, 2),
206201
'utf-8'
207202
);
208203

209204
const sidebars = require(SIDEBARS_PATH);
210205

211-
const categoryItem = sidebars.websiteSidebar.find((item) =>{
206+
const categoryItem = sidebars.websiteSidebar.find((item) => {
212207
return item.label === category;
213208
});
214209

215-
if(!categoryItem){
216-
console.error(`There was an error adding the element to "sidebars.js" under the category ${category}, please do it manually`);
210+
if (!categoryItem) {
211+
console.error(
212+
`There was an error adding the element to "sidebars.js" under the category ${category}, please do it manually`
213+
);
217214
process.exit(1);
218215
}
219216

sidebars.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,19 @@ module.exports = {
1010
'webview2',
1111
],
1212
},
13-
'direct-drawing',
14-
'platform-controls'
13+
{
14+
type: 'category',
15+
label: 'Platform controls',
16+
items: [
17+
'platform-controls',
18+
],
19+
},
20+
{
21+
type: 'category',
22+
label: 'Direct drawing',
23+
items: [
24+
'direct-drawing',
25+
],
26+
},
1527
],
1628
};

0 commit comments

Comments
 (0)