window.PagesPathActions = { async renameCurrentPath() { const currentPath = location.pathname.replace( /^\/e/, "", ) const nextPath = prompt( "Rename path:", currentPath, ) if ( !nextPath || nextPath === currentPath ) { return } const res = await fetch( "/_/api/v1/path/rename", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ old_path: currentPath, new_path: nextPath, }), }, ) if (!res.ok) { alert( "rename failed", ) return } location.href = "/e" + nextPath }, async removeCurrentPath() { const currentPath = location.pathname.replace( /^\/e/, "", ) if ( !confirm( "Remove path?\n\n" + currentPath, ) ) { return } const res = await fetch( "/_/api/v1/path/remove", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ path: currentPath, }), }, ) if (!res.ok) { alert( "remove failed", ) return } location.href = "/" }, }