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-8/

International Blog URL Generator

Build a system that generates URL-friendly slugs for blog post titles in multiple languages, ensuring proper locale-specific character transliteration.

Requirements

You need to implement a blog URL generator that:

  1. Takes blog post titles in various languages and converts them into URL-safe slugs
  2. Applies locale-specific transliteration rules based on the content's language
  3. Handles Swedish, German, and Turkish content with appropriate locale settings
  4. Provides consistent slug generation across the application

Locale-Specific Requirements

Your implementation must handle these specific cases:

  • Swedish content: Swedish characters (å, ä, ö) should follow Swedish transliteration conventions
  • German content: German umlauts (ä, ö, ü) and ß should follow German transliteration rules
  • Turkish content: Turkish-specific characters (İ, ı, Ş, ş, Ç, ç, Ğ, ğ) should be transliterated according to Turkish conventions
  • Mixed/Default content: Content without a specific locale should use default transliteration

Function Signatures

Implement a module that exports:

  1. A function generateSlug(title: string, locale?: string): string that generates a slug with optional locale
  2. A function generateLocalizedSlugs(posts: Array<{title: string, language: string}>): Array<{title: string, slug: string}> that processes multiple posts with their respective locales

Test Cases

  • Given the Swedish title "Räksmörgås och öl", with locale 'sv', returns 'raksmorgas-och-ol' @test
  • Given the German title "Föhn und Größe", with locale 'de', returns 'foehn-und-groesse' @test
  • Given the Turkish title "İstanbul Şehir Rehberi", with locale 'tr', returns 'istanbul-sehir-rehberi' @test
  • Given the title "Räksmörgås" without a locale parameter, returns a slug using default transliteration 'raeksmoergas' @test
  • Given an array of posts with mixed languages, returns correctly transliterated slugs for each based on their language property @test

@generates

API

/**
 * Generates a URL-safe slug from a title with optional locale-specific transliteration
 * @param title - The blog post title to convert
 * @param locale - Optional locale code (e.g., 'sv', 'de', 'tr') for locale-specific transliteration
 * @returns A URL-safe slug string
 */
export function generateSlug(title: string, locale?: string): string;

/**
 * Processes multiple blog posts and generates localized slugs
 * @param posts - Array of posts with title and language properties
 * @returns Array of posts with their generated slugs
 */
export function generateLocalizedSlugs(
  posts: Array<{title: string, language: string}>
): Array<{title: string, slug: string}>;

Dependencies { .dependencies }

@sindresorhus/slugify { .dependency }

Provides string slugification with comprehensive Unicode transliteration and locale-specific conversion support.

Install with Tessl CLI

npx tessl i tessl/npm-sindresorhus--slugify

tile.json