diff --git a/src/integrations/providers/algolia/implementation.js b/src/integrations/providers/algolia/implementation.js index 4eb90d2c..034c5e49 100644 --- a/src/integrations/providers/algolia/implementation.js +++ b/src/integrations/providers/algolia/implementation.js @@ -1,5 +1,6 @@ import { createEntry } from '../../../valueObjects/Entry'; import _ from 'lodash'; +import Collection from '../../../valueObjects/Collection'; function getSlug(path) { const m = path.match(/([^\/]+?)(\.[^\/\.]+)?$/); @@ -101,11 +102,12 @@ export default class Algolia { if (this.entriesCache.collection === collection && this.entriesCache.page === page) { return Promise.resolve({ page: this.entriesCache.page, entries: this.entriesCache.entries }); } else { + const collectionModel = new Collection(collection); return this.request(`${ this.searchURL }/indexes/${ collection.get('name') }`, { params: { page }, }).then((response) => { const entries = response.hits.map((hit) => { - const slug = hit.slug || getSlug(hit.path); + const slug = collectionModel.entrySlug(hit.path); return createEntry(collection.get('name'), slug, hit.path, { data: hit.data, partial: true }); }); this.entriesCache = { collection, pagination: response.page, entries };