CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-sindresorhus--slugify

Slugify a string with comprehensive Unicode transliteration and extensive customization options

94

1.34x
Overview
Eval results
Files

task.mdevals/scenario-4/

URL Path Generator

Build a utility that generates URL paths from article metadata using custom separator patterns for different content types.

Requirements

Create a Node.js module that exports a function generateUrlPaths(articles) which takes an array of article objects and returns an array of URL path strings.

Each article object has the following properties:

  • title (string): The article title
  • category (string): The content category ('blog', 'docs', or 'news')

The function should generate URL-friendly paths with category-specific separators:

  • Blog articles: Use double underscore separator (__)
  • Documentation: Use double dash separator (--)
  • News articles: Use double colon separator (::)

The generated path format should be: category/slugified-title where the slugified title uses the appropriate multi-character separator for that category.

Test Cases

  • Given an article {title: "Hello World", category: "blog"}, it returns "blog/hello__world" @test
  • Given an article {title: "API Reference", category: "docs"}, it returns "docs/api--reference" @test
  • Given an article {title: "Breaking News", category: "news"}, it returns "news/breaking::news" @test
  • Given multiple articles with different categories, it returns an array with correctly formatted paths for each @test

Implementation

@generates

API

/**
 * Generates URL paths from article metadata with category-specific separators.
 *
 * @param {Array<{title: string, category: string}>} articles - Array of article objects
 * @returns {string[]} Array of generated URL paths
 */
function generateUrlPaths(articles) {
  // IMPLEMENTATION HERE
}

module.exports = { generateUrlPaths };

Dependencies { .dependencies }

@sindresorhus/slugify { .dependency }

Provides string slugification with customizable separators.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-sindresorhus--slugify

tile.json