Skip to content

Commit ec33733

Browse files
committed
Resolve the functionality to duplicate a page that has been already duplicated
1 parent 47321cd commit ec33733

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/studio/src/routes/editor/LayersPanel/Tree/PageTreeNode.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ const PageTreeNode: React.FC<PageTreeNodeProps> = ({ node, style }) => {
7575

7676
const handleDuplicate = async () => {
7777
try {
78-
await editorEngine.pages.duplicatePage(node.data.path, node.data.path);
78+
const basePath = node.data.path;
79+
const newPath = basePath.replace(/(\/[^/]+)$/, (match) => {
80+
const baseName = getBaseName(match);
81+
const newName = `${baseName}1`;
82+
return `/${newName}`;
83+
});
84+
await editorEngine.pages.duplicatePage(basePath, newPath);
7985

8086
toast({
8187
title: 'Page duplicated',

0 commit comments

Comments
 (0)