Best way to generate url-friendly unique slug for document

What is the best way to generate a unique, readable slug for a document? Say you want to use it as a route like myapp.com/my-blog--post. Is there a shortcut to doing this using builtin FQL functions? In my case the document has a title so I was thinking of doing a combination of title with spaces replaced by hyphens and special characters removed and then concatenating a hash of the ref ID, does that make sense?

To get a unique short string based on an ID generated by Fauna you could lookup a utility I made some time ago: https://github.com/gahabeen/nanohash.

Let me know if you need help.

2 Likes

Or https://github.com/ai/nanoid

3 Likes