Fix M-4: punctuation-only page name yields empty slug ('.html')
slugify('!!!') stripped down to '' since punctuation-only names have no
a-z0-9 characters left; buildSavePayload then wrote filename = '' +
'.html'. slugify now falls back to 'page' when the computed slug is
empty, so uniqueSlug's existing dedupe (page, page-2, ...) applies same
as any other collision. Landing page slug stays forced to 'index'.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -181,12 +181,17 @@ const PageContext = createContext<PageContextValue>({
|
||||
export const usePages = () => useContext(PageContext);
|
||||
|
||||
function slugify(name: string): string {
|
||||
return name
|
||||
const slug = name
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/[^a-z0-9\s-]/g, '')
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/-+/g, '-');
|
||||
// M-4: a punctuation-only name (e.g. "!!!") strips down to '' -- without a
|
||||
// fallback, buildSavePayload would write filename = '' + '.html' for that
|
||||
// page. uniqueSlug's existing dedupe logic then applies on top of this
|
||||
// fallback the same way it does for any other base ('page', 'page-2', ...).
|
||||
return slug || 'page';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user