All files / apps/developer-portal/layers/docs/shared docPages.ts

100% Statements 10/10
100% Branches 2/2
100% Functions 4/4
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  43x         43x 117x   94x   95x         43x 195x     43x 32x  
/** A folder name is what the workspace calls a project; a reader wants its name, not its slug. */
const NAME_OVERRIDES: Record<string, string> = {
    ui: "UI",
    i18n: "i18n",
};
 
export const toTitleCase = (name: string): string => {
    if (NAME_OVERRIDES[name]) return NAME_OVERRIDES[name];
 
    return name
        .split("-")
        .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
        .join(" ");
};
 
/** Titles here open with an emoji by house style; in a dense nav it is noise twice over. */
export const stripLeadingEmoji = (title: string): string =>
    title.replace(/^[^\p{L}\p{N}`@]+/u, "").trim();
 
/** `@nuxt/content` keys a page by a lower-cased, extension-less route; the collector keys it by the real repo path — anything joining the two must cross here first. */
export const toCollectionPath = (repoPath: string): string =>
    `/${repoPath.replace(/\.mdx?$/i, "").toLowerCase()}`;