diff --git a/src/blocks/interactive/movie-search/view.js b/src/blocks/interactive/movie-search/view.js index ddc2875..cfb44fc 100644 --- a/src/blocks/interactive/movie-search/view.js +++ b/src/blocks/interactive/movie-search/view.js @@ -1,13 +1,15 @@ // Disclaimer: Importing the `store` using a global is just a temporary solution. const { store, navigate } = window.__experimentalInteractivity; +const siteRoot = document.querySelector('link[rel*="api.w.org"]').href.replace('/wp-json/', ''); + const updateURL = async (value) => { const url = new URL(window.location); url.searchParams.set('post_type', 'movies'); url.searchParams.set('orderby', 'name'); url.searchParams.set('order', 'asc'); url.searchParams.set('s', value); - await navigate(`/${url.search}${url.hash}`); + await navigate(`${siteRoot}/${url.search}${url.hash}`); }; store({ @@ -23,7 +25,7 @@ store({ if (value === '') { // If the search is empty, navigate to the home page. - await navigate('/'); + await navigate(siteRoot); } else { // If not, navigate to the new URL. await updateURL(value);