All files / src/aggregator/metadata slug.ts

100% Statements 2/2
50% Branches 1/2
100% Functions 2/2
100% Lines 2/2

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 24 25 26 27                                        1094x   1164x        
// SPDX-FileCopyrightText: 2024-2026 Hack23 AB
// SPDX-License-Identifier: Apache-2.0
 
/**
 * @module Aggregator/Metadata/Slug
 * @description Pure slug-humanisation helper extracted from
 * `article-metadata.ts`. Kept as a leaf module so heading-rule and
 * template-fallback helpers can depend on it without pulling in the
 * full metadata resolver.
 */
 
/**
 * Humanise an `article-type` slug the same way `humanizeStem` does in
 * `src/aggregator/analysis-aggregator.ts`. Kept in sync by value — we
 * deliberately do not import the private helper.
 *
 * @param slug - Slug like `week-ahead` or `breaking_news`
 * @returns Title-cased humanised form (`Week Ahead`, `Breaking News`)
 */
export function humanizeSlug(slug: string): string {
  return slug
    .split(/[-_]/g)
    .map((seg) => (seg ? seg.charAt(0).toUpperCase() + seg.slice(1) : seg))
    .join(' ')
    .trim();
}