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

View file

@ -4,23 +4,32 @@ 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) => {
if ( !clientOverride ){
// Return the base page if there are no client override.
return processPageData(baseResponse, null);
}
else {
// Else get the client override page.
return store.getPageData(pageName) return store.getPageData(pageName)
.then( .then(
// Get the client override if it exists.
(clientResponse) => { (clientResponse) => {
// Process the client override if it exists.
return processPageData(baseResponse, clientResponse); return processPageData(baseResponse, clientResponse);
}, },
(error) => { (error) => {
// Process the just the base if no client override exists.
return processPageData(baseResponse, null); return processPageData(baseResponse, null);
} }
); );
} }
}
); );
}; };