fix(project-editor): ProjectValidator duplicate-slug check falls back to route when slug is unset
Mock bootstrap seed data populates page.route but never page.slug, so duplicateSlugIssues always collapsed every static page to the same undefined key and reported a false-positive duplicate-slugs issue, permanently blocking Publish. Fall back to route (leading slash stripped) when slug is missing or empty.
This commit is contained in:
@@ -41,7 +41,9 @@ export class ProjectValidator {
|
||||
if (!staticPages || Array.isArray(staticPages)) {
|
||||
return [];
|
||||
}
|
||||
const slugs = Object.values(staticPages).map(page => page.slug);
|
||||
const slugs = Object.values(staticPages).map(page =>
|
||||
page.slug && page.slug.trim() ? page.slug : (page.route ?? '').replace(/^\//, ''),
|
||||
);
|
||||
const hasDuplicates = slugs.some((slug, index) => slugs.indexOf(slug) !== index);
|
||||
return hasDuplicates ? [{ code: 'duplicate-slugs', message: 'builder.validationDuplicateSlugs' }] : [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user