Skip to content

Commit 95b6cec

Browse files
committed
refactor(update-sidebars-o1js-api.js): inline capitalizeWords function to simplify code
feat(update-sidebars-o1js-api.js): rename 'README' to 'Introduction' for better clarity feat(update-sidebars-o1js-api.js): add SEO data to README file to improve search engine visibility
1 parent 25afb40 commit 95b6cec

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

scripts/update-sidebars-o1js-api.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,43 @@ function findo1jsSidebar(sidebars) {
4949
};
5050
}
5151

52-
function capitalizeWords(str) {
53-
return str.replace(/\b\w/g, (char) => char.toUpperCase());
54-
}
55-
5652
function renameCategories(items) {
5753
items.forEach((item) => {
5854
if (item.type === 'category') {
59-
item.label = capitalizeWords(item.label);
55+
item.label = item.label.replace(/\b\w/g, (char) => char.toUpperCase());
6056
renameCategories(item.items);
6157
}
6258
});
59+
}
60+
61+
function renameReadme(items) {
6362
const overviewIndex = items.findIndex((item) => item.label === 'README');
6463
if (overviewIndex !== -1) {
6564
items[overviewIndex].label = 'Introduction';
6665
}
6766
}
6867

68+
function addSEODataToReadme(readmePath) {
69+
const fileContents = fs.readFileSync(readmePath, 'utf8');
70+
const seoData = `---
71+
title: o1js API Reference
72+
keywords:
73+
- o1js
74+
- API
75+
- Reference
76+
---\n\n`;
77+
fs.writeFileSync(readmePath, seoData + fileContents);
78+
}
79+
6980
const { zkAppCategory, o1jsAPICategory } = findo1jsSidebar(sidebars);
7081
const newAPISidebar = {
7182
type: 'category',
7283
label: 'o1js Reference',
7384
items: buildDirectoryStructure('./docs/zkapps/o1js-reference'),
7485
};
7586
renameCategories(newAPISidebar.items);
87+
renameReadme(newAPISidebar.items);
88+
addSEODataToReadme('./docs/zkapps/o1js-reference/README.mdx');
7689
sidebars.docs[zkAppCategory].items[o1jsAPICategory] = newAPISidebar;
7790

7891
fs.writeFileSync(

0 commit comments

Comments
 (0)