From f6a1718085134ca3c33cdbe7dcb8b141ccb9f80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1ssio=20Zen?= Date: Mon, 2 Jan 2017 17:31:01 -0200 Subject: [PATCH] Uniform slug generation --- src/integrations/providers/algolia/implementation.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/integrations/providers/algolia/implementation.js b/src/integrations/providers/algolia/implementation.js index 961cd613..58ecbf02 100644 --- a/src/integrations/providers/algolia/implementation.js +++ b/src/integrations/providers/algolia/implementation.js @@ -3,8 +3,7 @@ import { createEntry } from '../../../valueObjects/Entry'; import { selectEntrySlug } from '../../../reducers/collections'; function getSlug(path) { - const m = path.match(/([^\/]+?)(\.[^\/\.]+)?$/); - return m && m[1]; + return path.split('/').pop().replace(/\.[^\.]+$/, ''); } export default class Algolia { @@ -85,7 +84,7 @@ export default class Algolia { body: JSON.stringify({ requests: searchCollections }), }).then((response) => { const entries = response.results.map((result, index) => result.hits.map((hit) => { - const slug = hit.slug || getSlug(hit.path); + const slug = getSlug(hit.path); return createEntry(collections[index], slug, hit.path, { data: hit.data, partial: true }); }));