3e42d4b1be
fixes https://github.com/TryGhost/DevOps/issues/86 - this will now hash the files and append a cachebuster, so we never serve stale files again
23 lines
936 B
JavaScript
23 lines
936 B
JavaScript
import config from 'ghost-admin/config/environment';
|
|
import ghostPaths from 'ghost-admin/utils/ghost-paths';
|
|
|
|
export default async function fetchKoenigLexical() {
|
|
if (window['@tryghost/koenig-lexical']) {
|
|
return window['@tryghost/koenig-lexical'];
|
|
}
|
|
|
|
// If we pass an editor URL (the env var from the dev script), use that
|
|
// Else, if we pass a CDN URL, use that
|
|
// Else, use the asset root from the ghostPaths util
|
|
const baseUrl = (config.editorUrl || (config.cdnUrl ? `${config.cdnUrl}assets/koenig-lexical/` : `${ghostPaths().assetRootWithHost}koenig-lexical/`));
|
|
const url = new URL(`${baseUrl}${config.editorFilename}?v=${config.editorHash}`);
|
|
|
|
if (url.protocol === 'http:') {
|
|
await import(`http://${url.host}${url.pathname}${url.search}`);
|
|
} else {
|
|
await import(`https://${url.host}${url.pathname}${url.search}`);
|
|
}
|
|
|
|
return window['@tryghost/koenig-lexical'];
|
|
}
|