mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 18:01:36 +03:00
d8d0bc8bd9
no issue `show_title_and_feature_image` leads to more intuitive logic in themes and we can use `posts` rather than `posts_meta` as there are no longer row-length issues with MySQL 8. - removed original add-column migration that was never in a release - added new add-column migration that puts `show_title_and_feature_image` column with a default of `true` on the `posts` table - renamed property and default value everywhere - bumped `@tryghost/admin-api-schema` to allow the new property through at the API level
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
/* eslint-disable camelcase */
|
|
import ApplicationSerializer from 'ghost-admin/serializers/application';
|
|
import {EmbeddedRecordsMixin} from '@ember-data/serializer/rest';
|
|
|
|
export default class PostSerializer extends ApplicationSerializer.extend(EmbeddedRecordsMixin) {
|
|
// settings for the EmbeddedRecordsMixin.
|
|
attrs = {
|
|
authors: {embedded: 'always'},
|
|
tags: {embedded: 'always'},
|
|
publishedAtUTC: {key: 'published_at'},
|
|
createdAtUTC: {key: 'created_at'},
|
|
updatedAtUTC: {key: 'updated_at'},
|
|
email: {embedded: 'always'},
|
|
newsletter: {embedded: 'always'},
|
|
postRevisions: {embedded: 'always'}
|
|
};
|
|
|
|
serialize(snapshot/*, options*/) {
|
|
let json = super.serialize(...arguments);
|
|
|
|
// Inserted locally as a convenience.
|
|
delete json.author_id;
|
|
// Read-only virtual properties
|
|
delete json.uuid;
|
|
delete json.url;
|
|
delete json.send_email_when_published;
|
|
delete json.email_recipient_filter;
|
|
delete json.email;
|
|
delete json.newsletter;
|
|
// Deprecated property (replaced with data.authors)
|
|
delete json.author;
|
|
// Page-only properties
|
|
if (snapshot.modelName !== 'page') {
|
|
delete json.show_title_and_feature_image;
|
|
}
|
|
|
|
if (json.visibility === null) {
|
|
delete json.visibility;
|
|
delete json.visibility_filter;
|
|
delete json.tiers;
|
|
}
|
|
|
|
if (json.visibility === 'tiers') {
|
|
delete json.visibility_filter;
|
|
}
|
|
|
|
if (json.visibility === 'tiers' && !json.tiers?.length) {
|
|
delete json.visibility;
|
|
delete json.tiers;
|
|
}
|
|
|
|
return json;
|
|
}
|
|
}
|