MCPcopy Create free account
hub / github.com/code100x/cms / generateHandle

Function generateHandle

src/lib/utils.ts:316–361  ·  view source on GitHub ↗
(title: string)

Source from the content-addressed store, hash-verified

314};
315
316export const generateHandle = (title: string): string => {
317 const latinToEnglishMap: { [key: string]: string } = {
318 à: 'a',
319 á: 'a',
320 â: 'a',
321 ã: 'a',
322 ä: 'a',
323 å: 'a',
324 è: 'e',
325 é: 'e',
326 ê: 'e',
327 ë: 'e',
328 ì: 'i',
329 í: 'i',
330 î: 'i',
331 ï: 'i',
332 ò: 'o',
333 ó: 'o',
334 ô: 'o',
335 õ: 'o',
336 ö: 'o',
337 ù: 'u',
338 ú: 'u',
339 û: 'u',
340 ü: 'u',
341 ñ: 'n',
342 ç: 'c',
343 ß: 'ss',
344 ÿ: 'y',
345 œ: 'oe',
346 æ: 'ae',
347 };
348
349 const normalizedTitle = title
350 .normalize('NFD')
351 .replace(/[\u0300-\u036f]/g, '');
352
353 const handle = normalizedTitle
354 .toLowerCase()
355 .replace(/[^a-z0-9]+/g, '-')
356 .replace(/(^-|-$)/g, '')
357 // eslint-disable-next-line no-control-regex
358 .replace(/[^\x00-\x7F]/g, (char) => latinToEnglishMap[char] || '');
359
360 return handle;
361};
362
363export const getDisabledFeature = (feature: string): boolean => {
364 return (process.env.NEXT_PUBLIC_DISABLE_FEATURES || '')

Callers 2

createQuestionHandlerFunction · 0.90
updateQuestionHandlerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected