Skip to content

Commit

Permalink
delete boilerplate about page if launching Big Sky (#96041)
Browse files Browse the repository at this point in the history
  • Loading branch information
kthai15 authored Nov 5, 2024
1 parent 04dc2bd commit 9462f10
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ const LaunchBigSky: Step = function () {
const hasStaticHomepage = site?.options?.show_on_front === 'page' && site?.options?.page_on_front;
const assemblerThemeActive = site?.options?.theme_slug === 'pub/assembler';

const deletePage = async ( siteId: string, pageId: number ): Promise< boolean > => {
try {
await wpcomRequest( {
path: '/sites/' + siteId + '/pages/' + pageId,
method: 'DELETE',
apiNamespace: 'wp/v2',
} );
return true;
} catch ( error ) {
// fail silently here, just log an error and return false, Big Sky will still launch
// eslint-disable-next-line no-console
console.error( `Failed to delete page ${ pageId } for site ${ siteId }:`, error );
return false;
}
};

useEffect( () => {
if ( ! isLoading && ! isEligible ) {
window.location.assign( '/start' );
Expand Down Expand Up @@ -62,6 +78,9 @@ const LaunchBigSky: Step = function () {
);
}

// Delete the existing boilerplate about page, always has a page ID of 1
pendingActions.push( deletePage( selectedSiteId, 1 ) );

try {
const results = await Promise.all( pendingActions );
const siteURL = results[ 0 ].URL;
Expand Down

0 comments on commit 9462f10

Please sign in to comment.