Amélioration de l'ergonomie de l'interface et de la table de relecture
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 3m11s

This commit is contained in:
2026-08-31 20:52:55 +02:00
parent d008baf81b
commit 1c6c91d5ea
206 changed files with 74199 additions and 213 deletions

View File

@@ -0,0 +1,33 @@
import path from 'node:path';
const SLUG_MAX = 50;
/** Derive one clone-stable slug from a concrete file path or URL. */
export function slugFromTarget(resolved, { cwd = process.cwd() } = {}) {
if (!resolved || typeof resolved !== 'string') return null;
const trimmed = resolved.trim();
if (!trimmed) return null;
if (/^https?:\/\//i.test(trimmed)) {
let url;
try { url = new URL(trimmed); } catch { return null; }
return kebab(`${url.hostname}${url.pathname}`);
}
const abs = path.isAbsolute(trimmed) ? trimmed : path.resolve(cwd, trimmed);
let rel = path.relative(cwd, abs);
if (rel.startsWith('..') || path.isAbsolute(rel)) rel = path.basename(abs);
if (!rel || rel === '.') return null;
return kebab(rel);
}
export function kebab(value) {
const slug = String(value || '')
.toLowerCase()
.replace(/[/\\.]+/g, '-')
.replace(/[^a-z0-9-]+/g, '-')
.replace(/-+/g, '-')
.replace(/^-|-$/g, '');
if (!slug) return null;
return slug.length <= SLUG_MAX ? slug : slug.slice(slug.length - SLUG_MAX).replace(/^-/, '');
}