Skip to content

Commit

Permalink
Website: Use the default Blueprint if the one in the URL has a syntax…
Browse files Browse the repository at this point in the history
… error
  • Loading branch information
adamziel committed Oct 14, 2024
1 parent b39e308 commit 1cd30bf
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '../../lib/state/redux/store';
import { redirectTo } from '../../lib/state/url/router';
import { logger } from '@php-wasm/logger';
import { Blueprint } from '@wp-playground/blueprints';

/**
* Ensures the redux store always has an activeSite value.
Expand Down Expand Up @@ -85,11 +86,17 @@ export function EnsurePlaygroundSiteIsSelected({
// Lean on the Query API parameters and the Blueprint API to
// create the new site.
const url = new URL(window.location.href);
let blueprint: Blueprint | undefined = undefined;
try {
blueprint = await resolveBlueprintFromURL(url);
} catch (e) {
logger.error('Error resolving blueprint:', e);
}
// Create a new site otherwise
const newSiteInfo = await dispatch(
setTemporarySiteSpec({
metadata: {
originalBlueprint: await resolveBlueprintFromURL(url),
originalBlueprint: blueprint,
},
originalUrlParams: {
searchParams: Object.fromEntries(
Expand Down

0 comments on commit 1cd30bf

Please sign in to comment.