use createSlug

This commit is contained in:
Vesa Luusua 2017-08-15 14:19:11 +03:00
parent cd22fcd093
commit 48dbe8bf77
2 changed files with 4 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import { NamedLink, ResponsiveImage } from '../../components';
import * as propTypes from '../../util/propTypes';
import { convertMoneyToNumber } from '../../util/currency';
import { ensureListing, ensureUser } from '../../util/data';
import { createSlug } from '../../util/urlHelpers';
import css from './ListingCard.css';
@ -34,7 +35,7 @@ export const ListingCardComponent = props => {
const currentListing = ensureListing(listing);
const id = currentListing.id.uuid;
const { title = '', price } = currentListing.attributes;
const slug = encodeURIComponent(title.split(' ').join('-'));
const slug = createSlug(title);
const author = ensureUser(listing.author);
const authorName = `${author.attributes.profile.firstName} ${author.attributes.profile.lastName}`;
const firstImage = currentListing.images && currentListing.images.length > 0

View file

@ -9,6 +9,7 @@ import { formatMoney } from '../../util/currency';
import config from '../../config';
import { withFlattenedRoutes } from '../../util/contextHelpers';
import { createResourceLocatorString } from '../../util/routes';
import { createSlug } from '../../util/urlHelpers';
import { ResponsiveImage } from '../../components';
import css from './SearchMapListingCard.css';
@ -21,7 +22,7 @@ const getPixelPositionOffset = (width, height) => {
const createURL = (flattenedRoutes, history, listing) => {
const id = listing.id.uuid;
const slug = encodeURIComponent(listing.attributes.title.split(' ').join('-'));
const slug = createSlug(listing.attributes.title);
const pathParams = { id, slug };
return createResourceLocatorString('ListingPage', flattenedRoutes, pathParams, {});
};