Skip to content

Commit 568174d

Browse files
authored
docs: preserve entities names casing (#1086)
1 parent 6d9f91c commit 568174d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

docs/src/libs-plugin.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export function libsPlugin(opts: LibsLoaderOptions): StarlightPlugin {
174174
const id = name.startsWith('@') ? name.split('/')[1] : name;
175175
const outputRootDir = path.resolve(outDir, id);
176176
const outputApiDir = path.resolve(outputRootDir, 'api');
177-
const title = titleFromId(id);
177+
const title = titleFromIdCapitalized(id);
178178

179179
await processMarkdown({
180180
inputPath: path.resolve(baseDir, id, 'README.md'),
@@ -233,7 +233,7 @@ export function libsPlugin(opts: LibsLoaderOptions): StarlightPlugin {
233233
for (const file of opts.additionalFiles || []) {
234234
const fileName = path.basename(file.path).toLowerCase();
235235
const id = idFromFilename(fileName);
236-
const title = titleFromId(id);
236+
const title = titleFromIdCapitalized(id);
237237

238238
await processMarkdown({
239239
inputPath: path.resolve(file.path),
@@ -276,7 +276,11 @@ function titleFromFilename(fileName: string): string {
276276
}
277277

278278
function titleFromId(id: string): string {
279-
return id.replace(/-/g, ' ').replace(/\b\w/g, char => char.toUpperCase());
279+
return id.replace(/-/g, ' ');
280+
}
281+
282+
function titleFromIdCapitalized(id: string): string {
283+
return titleFromId(id).replace(/\b\w/g, char => char.toUpperCase());
280284
}
281285

282286
interface ProcessMarkdownOpts {

0 commit comments

Comments
 (0)