Skip to the content

Capsid menu

app/lib/kind-words.ts

16 lines and 3 functions in DrDustinEdwards/carrel, at commit d5d5e82 on 2026-10-24. This file on GitHub.

Functions

The functions of kind-words.ts
FunctionLinesComplexityCoveredCRAPMutation
kindWord5 to 82100%OkCRAP 2No data: mutation testing has not run on this repo yet
kindPlural11 to 16367%OkCRAP 3.3No data: mutation testing has not run on this repo yet
kindNoun19 to 192100%OkCRAP 2No data: mutation testing has not run on this repo yet

Imports

It imports no other module of this repo. Imported by app/components/editor/frontmatter-fields.tsx, app/lib/writing/binder.ts, app/routes/editor.tsx, app/routes/history.tsx, app/routes/project.tsx.

Source

// The words for a kind the site reports, so a phage is called a phage and not a post. Carrel has no
// list of kinds: these are made from the site's own kind name, whatever it is.

/** The kind as a heading word: "phage" is "Phage". An item with no kind is a post. */
export function kindWord(kind: string | null | undefined): string {
  const k = kind || "post";
  return `${k.charAt(0).toUpperCase()}${k.slice(1)}`;
}

/** The kind in the plural, as a heading word: "Posts", "Dictionaries", "Addresses". */
export function kindPlural(kind: string | null | undefined): string {
  const word = kindWord(kind);
  if (/[^aeiou]y$/i.test(word)) return `${word.slice(0, -1)}ies`;
  if (/(s|x|z|ch|sh)$/i.test(word)) return `${word}es`;
  return `${word}s`;
}

/** The kind inside a sentence: "this phage". */
export const kindNoun = (kind: string | null | undefined) => (kind || "post").toLowerCase();