This commit is contained in:
Jeremy Zimmerman 2022-12-09 16:00:31 -05:00
parent 40fbd295f5
commit 0a3f9c9df4

View file

@ -4,22 +4,31 @@ import { useMainStore } from '@/store';
export function fetchCmsContentForPage(issPage) { export function fetchCmsContentForPage(issPage) {
const store = useMainStore() const store = useMainStore()
const clientName = "ClientOverrideTest";//store.issConfig.clientName; const clientName = "ClientOverrideTest";//store.issConfig.clientName;
const pageName = issPage + (clientName.length == 0 ? "" : "_" + clientName); const clientOverride = (clientName.length == 0);
const pageName = issPage + (clientOverride ? "" : "_" + clientName.toLowerCase().replace(/ /g, ""));
return store.getPageData(issPage) return store.getPageData(issPage)
.then( .then(
// Get the base/default page first. // Get the base/default page first.
(baseResponse) => { (baseResponse) => {
return store.getPageData(pageName) if ( !clientOverride ){
.then( // Return the base page if there are no client override.
// Get the client override if it exists. return processPageData(baseResponse, null);
(clientResponse) => { }
return processPageData(baseResponse, clientResponse); else {
}, // Else get the client override page.
(error) => { return store.getPageData(pageName)
return processPageData(baseResponse, null); .then(
} (clientResponse) => {
); // Process the client override if it exists.
return processPageData(baseResponse, clientResponse);
},
(error) => {
// Process the just the base if no client override exists.
return processPageData(baseResponse, null);
}
);
}
} }
); );
}; };