Curating Posts
Posts are looking pretty snazzy now, but we still don’t have a way of easily finding posts a user might want to see. Discoverability of new content is integral to social media platforms, so we should really add this.
The first discoverability feature we’ll address is tags. We implemented the Markdown for tags earlier—now let’s add the queries and page to browse posts by tag.
Tags
We’re going to use a PostgreSQL regex condition on our query, but we don’t want to require knowledge of PostgreSQL specifics in our guestbook.messages namespace. So we’ll use Clojure expressions in HugSQL to generate our regex inside our query.
First, let’s create a namespace guestbook.db.util and write a helper function there:
Get Web Development with Clojure, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.