diff --git a/ghost/collections/src/Collection.ts b/ghost/collections/src/Collection.ts index 39d2dc6029..a83ea91ff6 100644 --- a/ghost/collections/src/Collection.ts +++ b/ghost/collections/src/Collection.ts @@ -49,7 +49,7 @@ export class Collection { createdAt: Date; updatedAt: Date; get deletable() { - return this.slug !== 'index' && this.slug !== 'featured'; + return this.slug !== 'latest' && this.slug !== 'featured'; } private _deleted: boolean = false; @@ -69,7 +69,7 @@ export class Collection { } public async edit(data: Partial, uniqueChecker: UniqueChecker) { - if (this.type === 'automatic' && this.slug !== 'index' && (data.filter === null || data.filter === '')) { + if (this.type === 'automatic' && this.slug !== 'latest' && (data.filter === null || data.filter === '')) { throw new ValidationError({ message: tpl(messages.invalidFilterProvided.message), context: tpl(messages.invalidFilterProvided.context) @@ -201,7 +201,7 @@ export class Collection { }); } - if (data.type === 'automatic' && (data.slug !== 'index') && !data.filter) { + if (data.type === 'automatic' && (data.slug !== 'latest') && !data.filter) { // @NOTE: add filter validation here throw new ValidationError({ message: tpl(messages.invalidFilterProvided.message), diff --git a/ghost/collections/test/Collection.test.ts b/ghost/collections/test/Collection.test.ts index f4a2ac42e6..c3a0e30f42 100644 --- a/ghost/collections/test/Collection.test.ts +++ b/ghost/collections/test/Collection.test.ts @@ -210,20 +210,20 @@ describe('Collection', function () { }); }); - it('Does not throw when collection filter is empty for automatic "index" collection', async function (){ + it('Does not throw when collection filter is empty for automatic "latest" collection', async function (){ const collection = await Collection.create({ - title: 'Index', - slug: 'index', + title: 'Latest', + slug: 'latest', type: 'automatic', filter: '' }); const editedCollection = await collection.edit({ - title: 'Edited index', + title: 'Edited latest', filter: '' }, uniqueChecker); - assert.equal(editedCollection.title, 'Edited index'); + assert.equal(editedCollection.title, 'Edited latest'); assert.equal(editedCollection.filter, ''); }); }); @@ -303,10 +303,10 @@ describe('Collection', function () { assert.equal(collection.posts.length, 0); }); - it('Cannot set index collection to deleted', async function () { + it('Cannot set "latest" collection to deleted', async function () { const collection = await Collection.create({ title: 'Testing adding posts', - slug: 'index' + slug: 'latest' }); assert.equal(collection.deleted, false); diff --git a/ghost/core/core/server/data/migrations/versions/5.55/2023-07-07-14-15-32-add-built-in-collections.js b/ghost/core/core/server/data/migrations/versions/5.55/2023-07-10-05-15-55-add-built-in-collections.js similarity index 78% rename from ghost/core/core/server/data/migrations/versions/5.55/2023-07-07-14-15-32-add-built-in-collections.js rename to ghost/core/core/server/data/migrations/versions/5.55/2023-07-10-05-15-55-add-built-in-collections.js index 1f86b570f3..003d14a9ad 100644 --- a/ghost/core/core/server/data/migrations/versions/5.55/2023-07-07-14-15-32-add-built-in-collections.js +++ b/ghost/core/core/server/data/migrations/versions/5.55/2023-07-10-05-15-55-add-built-in-collections.js @@ -6,19 +6,19 @@ module.exports = createTransactionalMigration( async function up(knex) { logging.info('Creating built in collections'); - const existingIndexCollection = await knex('collections') + const existingLatestCollection = await knex('collections') .where({ - slug: 'index' + slug: 'latest' }) .first(); - if (existingIndexCollection) { - logging.warn('Index collection already exists, skipping'); + if (existingLatestCollection) { + logging.warn('Latest collection already exists, skipping'); } else { await knex('collections').insert({ id: (new ObjectID()).toHexString(), - name: 'Index', - slug: 'index', + title: 'Latest', + slug: 'latest', description: 'Collection with all posts', type: 'automatic', filter: '', @@ -33,11 +33,11 @@ module.exports = createTransactionalMigration( .first(); if (existingFeaturedCollection) { - logging.warn('Index collection already exists, skipping'); + logging.warn('Featured collection already exists, skipping'); } else { await knex('collections').insert({ id: (new ObjectID()).toHexString(), - name: 'Featured', + title: 'Featured', slug: 'featured', description: 'Collection of featured posts', type: 'automatic', @@ -50,7 +50,7 @@ module.exports = createTransactionalMigration( logging.info('Deleting built in collections'); await knex('collections').where({ - slug: 'index' + slug: 'latest' }).del(); await knex('collections').where({ diff --git a/ghost/core/core/server/data/schema/fixtures/fixtures.json b/ghost/core/core/server/data/schema/fixtures/fixtures.json index c90fe896ae..d22facceaa 100644 --- a/ghost/core/core/server/data/schema/fixtures/fixtures.json +++ b/ghost/core/core/server/data/schema/fixtures/fixtures.json @@ -4,8 +4,8 @@ "name": "Collection", "entries": [ { - "title": "Index", - "slug": "index", + "title": "Latest", + "slug": "latest", "description": "Collection with all posts", "type": "automatic", "filter": ""