2019-02-25 17:55:55 +03:00
|
|
|
import ApplicationAdapter from 'ghost-admin/adapters/application';
|
|
|
|
|
2022-02-02 19:57:22 +03:00
|
|
|
export default class Page extends ApplicationAdapter {
|
2019-02-25 17:55:55 +03:00
|
|
|
// posts and pages now include everything by default
|
|
|
|
buildIncludeURL(store, modelName, id, snapshot, requestType, query) {
|
2023-06-16 14:24:02 +03:00
|
|
|
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();
|
2022-02-02 19:57:22 +03:00
|
|
|
}
|
2019-02-25 17:55:55 +03:00
|
|
|
|
2022-09-15 19:40:45 +03:00
|
|
|
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
|
2022-09-13 23:01:53 +03:00
|
|
|
}
|
|
|
|
|
2022-09-15 19:40:45 +03:00
|
|
|
return url;
|
2019-02-25 17:55:55 +03:00
|
|
|
}
|
2022-09-16 14:54:43 +03:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
2022-02-02 19:57:22 +03:00
|
|
|
}
|