Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pretty URL slugs to listing pages #233

Merged
merged 3 commits into from May 6, 2020
Merged

Add pretty URL slugs to listing pages #233

merged 3 commits into from May 6, 2020

Conversation

bencpeters
Copy link
Collaborator

@bencpeters bencpeters commented Apr 28, 2020

Add pretty URL slugs to listing pages

This PR adds descriptive url "slugs" to the end of listing page URLs:

/listing/jsQvgvy6eJy56TNCFfQp8 => /listing/jsQvgvy6eJy56TNCFfQp8/the_triton_55_triton_park_lane_foster_city_ca

The bare "id-only" URLs will still work; they issue an immediate 301 redirect to the pretty version. This PR adds a general purpose Redirect component to accomplish this.

The url slug is available as an attribute urlSlug on the Listing type.

Minor version bump of eslint-typescript to allow function definitions. This was necessary to avoid an eslint error on this line.

Closes #215

@bencpeters bencpeters requested a review from bk3c April 28, 2020 18:05
@exygy-dev exygy-dev temporarily deployed to bloom-refere-add-url-sl-lbzwj2 April 28, 2020 18:06 Inactive
@exygy-dev exygy-dev temporarily deployed to bloom-refere-add-url-sl-orye9u April 28, 2020 18:08 Inactive
@jaredcwhite
Copy link
Collaborator

@bencpeters Nice solution! I'm wondering if we even need the guid in the the URL though? The number of available listings isn't that high so certainly no real risk of slug collision.

@bencpeters
Copy link
Collaborator Author

@bencpeters Nice solution! I'm wondering if we even need the guid in the the URL though? The number of available listings isn't that high so certainly no real risk of slug collision.

Personally, I like having the guid in there - it allows us to keep a "stable" URL in cases where the listing name changes (or maybe the address is incomplete/incorrect to start with and gets updated?). I could also see a higher chance of slug collisions in a multi-unit building - maybe the address is the same for all of them if the listing mistakenly doesn't include a unit number?

I don't feel super strongly on it though.

@jaredcwhite
Copy link
Collaborator

it allows us to keep a "stable" URL in cases where the listing name changes

That's a good point. Probably wouldn't happen after a listing goes live, but during development I could see that. Maybe we can knock the id length down to 8 characters or something of that nature?

@bencpeters
Copy link
Collaborator Author

That's a good point. Probably wouldn't happen after a listing goes live, but during development I could see that. Maybe we can knock the id length down to 8 characters or something of that nature?

Ya, that seems reasonable. Where are those IDs generated right now? I just saw them listed in the JSON data files?

@jaredcwhite
Copy link
Collaborator

Now that you mention it, they are totally arbitrary (hard-coded into the JSON). So perhaps we can file that as a separate issue related to the future Listings service.

@bk3c
Copy link
Contributor

bk3c commented May 4, 2020

FWIW, I'd definitely be in favor of shorter nanoids. Perhaps 8 characters, which should give us a 1% chance of collision every ~239 years if we generate 1/hr? I'm open to other lengths, though.

@bk3c bk3c merged commit 6d4a204 into master May 6, 2020
bk3c referenced this pull request in housingbayarea/bloom May 15, 2020
* Fix unit summary availability (core #224)
* Fixes for building criteria and preferences on listing (core #223)
* Insert GTM tags into page (core #195)
* Make floor optional for listings (core #225)
* Style changes (core #228)
* Added .idea (WebStorm config) to gitignore (core #234)
* Add .vscode to .gitignore (core #235)
* Add pretty URL slugs to listing pages (core #233)
* Add local development and dev site GTM keys (core #240)
* tech demo version "0.1" of Submit an Application form (core #232)
* Add lerna (core #226)
* fix production env key in netlify.toml (core #252)
* Upgrade prettier (core #214)
* Minor dependency updates to build and test tools (core #264)
* catch apps up with prettier 2
* match next.config with reference
* add redirect module now that it's enabled

Co-authored-by: Marcin Jędras <mjjedras@gmail.com>
Co-authored-by: Jared White <jared@jaredwhite.com>
Co-authored-by: Ben Kutler <ben@benkutler.com>
Co-authored-by: Jesse James Arnold <jesse.james@exygy.com>
Co-authored-by: Jesse Arnold <jessearnold@Jesses-MacBook-Pro.local>
Co-authored-by: Ben Peters <bencpeters@gmail.com>
@bk3c bk3c deleted the add-url-slugs branch June 2, 2020 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display meaningful urls and deeplinks for listing
4 participants