mirror of
https://github.com/gromlab-ru/slm-design.git
synced 2026-08-22 07:30:16 +03:00
feat: add example
This commit is contained in:
14
scripts/lib/slugify-heading.mjs
Normal file
14
scripts/lib/slugify-heading.mjs
Normal file
@@ -0,0 +1,14 @@
|
||||
const reservedLayerSlugs = new Set(['app', 'compositions', 'domains', 'infra', 'ui', 'shared']);
|
||||
|
||||
export const slugifyHeading = (value) => {
|
||||
const slug = value
|
||||
.replace(/<[^>]+>/g, '')
|
||||
.replace(/`/g, '')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/[^\p{L}\p{N}_-]/gu, '')
|
||||
.replace(/-+/g, '-');
|
||||
|
||||
return reservedLayerSlugs.has(slug) ? `layer-${slug}` : slug;
|
||||
};
|
||||
Reference in New Issue
Block a user