6 ms·
For Canny, I wrote some awesome code that I'm proud of that turns a "post title" into a unique URL. https://react-native.canny.io/feature-requests/p/headless-j
by a13n 9y ago
For Canny, I wrote some awesome code that I'm proud of that turns a "post title" into a unique URL.
https://react-native.canny.io/feature-requests/p/headless-js-for-ios https://react-native.canny.io/feature-requests/p/headless-js...
For example, a post with title "post title" will get url "post-title".
Then a second post with title "post title" will get url "post-title-1".
Since there's only one URL part associated with each post, it's a unique identifier.
This gets rid of the ugly id in the URL, for epic URL awesomeness.
Furthermore, if you edit the first post to have "new post title" then its URL will update to "new-post-title", but "post-title" will still redirect to "new-post-title".
Someday I'm gonna open source a lib that lets you easily add awesome URLs to your app. :)
- jlg23 9y ago> For Canny, I wrote some awesome code that I'm proud of that turns a "post title" into a unique URL. Did you mean "slug"? What you are describing is a basic feature of most blogging software since the inception of blogs...
- a13n 9y agoIt's way more than that. – Automatically handling duplicates – Avoiding needing to include the unique ID in the URL – Updating the URL after editing the post – Redirecting previous versions to the new version
- always_good 9y agoThe annoying part is doing the database lookups to check for collisions / canonicalization, so what would your lib be generalizing?
- a13n 9y agoYeah good point. Maybe it'd be better as a blog post with an associated repo in one implementation (Node + Mongo) and great documentation.