rename folder feature added. 4s edit wait, 6s cooldown adjust
Some checks failed
Zettelclean CI / build (20.x) (push) Has been cancelled
Zettelclean CI / build (22.x) (push) Has been cancelled
Zettelclean CI / build (24.x) (push) Has been cancelled
Release Zettelclean / build (push) Has been cancelled

This commit is contained in:
2026-07-29 11:07:30 -03:00
parent e83b95c6ee
commit 35cb6dd976
8 changed files with 82 additions and 33 deletions

View File

@@ -23,9 +23,10 @@
// in isolation. The transform is always one-way (H1 -> filename), which lets us
// freely drop characters without worrying about a reverse mapping.
// A TIMEID is a leading run of 12 to 18 digits, ending at a dash or end-of-name.
// A TIMEID is the leading run of 12 to 18 digits, ending at any non-digit or
// end-of-name (so "202607290947 test" and "202607290947-slug" both qualify).
// 12-18 because collision-avoidance may append extra digits to a 14-digit stamp.
const TIMEID_RE = /^(\d{12,18})(?=-|$)/;
const TIMEID_RE = /^(\d{12,18})(?=\D|$)/;
// Return the immutable id prefix, or null if this file is not a zettel.
export function extractTimeId(basename: string): string | null {
@@ -33,13 +34,13 @@ export function extractTimeId(basename: string): string | null {
return m?.[1] ?? null;
}
// H1 text -> kebab slug. sanifize as inspiration, deliberately simpler.
export function generateSlug(heading: string): string {
return heading
// text (an H1 or a folder name) -> ASCII, case-preserving, dash-separated slug.
// Shared by the file-rename sync and the folder-slug menu.
export function generateSlug(text: string): string {
return text
.normalize('NFKD') // split accented letters into base + combining mark
.replace(/[̀-ͯ]/g, '') // strip the combining marks (c-cedilla -> c)
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-') // any run of non-alphanumerics -> one dash
.replace(/[^a-zA-Z0-9]+/g, '-') // non-alphanumerics -> one dash (case kept)
.replace(/^-+|-+$/g, ''); // trim leading/trailing dashes
}