Skip to content

Commit 099fe8f

Browse files
committed
Fix missing functions in See Also section
1 parent ba63f13 commit 099fe8f

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

web/src/utils/functions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ let functionsByTypeByCategory: FunctionsByTypeByCategory = {
165165

166166
for (let func of functionsCollection) {
167167
let folder = path.basename(path.dirname(func.filePath || ''));
168-
folder = folder.replace(/_/g, ' ');
169168

170169
if (!functionsByCategory[folder]) {
171170
functionsByCategory[folder] = [];

web/src/utils/general.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,22 @@ const titleCase = (str: string) =>
4747
str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
4848

4949
const makeTitle = (subType: string, category: string, type: string): string => {
50-
const isUpperCase = category === category.toUpperCase();
51-
const categoryPart = isUpperCase ? category : titleCase(category);
52-
const typePart = titleCase(type);
50+
const displayName = (name: string) => name.replace(/_/g, ' ');
51+
52+
const smartTitleCase = (str: string) => {
53+
return str
54+
.split(' ')
55+
.map(word => (/^[A-Z0-9]+$/.test(word) ? word : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()))
56+
.join(' ');
57+
};
58+
59+
const categoryPart = smartTitleCase(displayName(category));
60+
const typePart = smartTitleCase(type);
61+
5362
if (subType === 'any') {
5463
return `${categoryPart} ${typePart}`;
5564
} else {
56-
const isUpperCase2 = subType === subType.toUpperCase();
57-
const subTypePart = isUpperCase2 ? subType : titleCase(subType);
65+
const subTypePart = smartTitleCase(displayName(subType));
5866
return `${subTypePart} ${categoryPart} ${typePart}`;
5967
}
6068
};

0 commit comments

Comments
 (0)