mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
77e3b3e947
closes https://github.com/TryGhost/Team/issues/3491 - the `PostRevisionModel` had a `belongsTo` relation to Post which resulted in the Page model returning an empty array in the `post_revisions` property. - Simply removing it fixed it. refs https://ghost.slack.com/archives/C02G9E68C/p1686912389383579?thread_ts=1686909240.034419&cid=C02G9E68C
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
import ApplicationAdapter from 'ghost-admin/adapters/application';
|
|
|
|
export default class Page extends ApplicationAdapter {
|
|
// posts and pages now include everything by default
|
|
buildIncludeURL(store, modelName, id, snapshot, requestType, query) {
|
|
const url = this.buildURL(modelName, id, snapshot, requestType, query);
|
|
const parsedUrl = new URL(url);
|
|
|
|
if (snapshot?.adapterOptions?.saveRevision) {
|
|
const saveRevision = snapshot.adapterOptions.saveRevision;
|
|
parsedUrl.searchParams.append('save_revision', saveRevision);
|
|
}
|
|
|
|
return parsedUrl.toString();
|
|
}
|
|
|
|
buildURL() {
|
|
const url = super.buildURL(...arguments);
|
|
|
|
try {
|
|
const parsedUrl = new URL(url);
|
|
if (!parsedUrl.searchParams.get('formats')) {
|
|
parsedUrl.searchParams.set('formats', 'mobiledoc,lexical');
|
|
return parsedUrl.href;
|
|
}
|
|
} catch (e) {
|
|
// noop, just use the original url
|
|
console.error('Couldn\'t parse URL', e); // eslint-disable-line
|
|
}
|
|
|
|
return url;
|
|
}
|
|
|
|
// posts and pages now include all relations by default so we don't want
|
|
// EmbeddedRelationAdapter.buildQuery adding an `?include=` param that
|
|
// overrides the defaults with a more restrictive list
|
|
buildQuery(store, modelName, options) {
|
|
return options;
|
|
}
|
|
}
|