-
Notifications
You must be signed in to change notification settings - Fork 0
Listings
Listings are the lifeblood of Peels. They can be of the following types:
- Residential
- Community
- Business
Most fields vary depending on the list type, but each must have at least map coordinates and scrap acceptance or donation details.
External links are a great way for compost donors to get an idea of the community spot or business they might donate scraps to or pick up from. Hosts typically link to their websites or social media pages that often include recent posts, opening hours, and volunteer information.
Community and business listings have an optional Links section. We use the built-in input type="url"
with very basic https?://.+
pattern matching for values here. Although quite restrictive, and perhaps difficult for non-technical users (who may enter a URL without the protocol), this ensures links are almost always robust, with minimal code bloat.
You'd be surprised by the amount of clearly wrong URLs that are entered that pass through advanced URL validators. For example, a value of type Instagram:@example
passes many basic URL validators but won't resolve, since it isn't a valid URL.
All listing types have an About textfield, presented as Donation details for business listings. Although it's discouraged, some hosts drop raw URLs and email addresses in this description, mixed in with text.
Given this reality, the ListingRead
component renders the description using a MultiParagraphCluster
component, which in turn uses parseTextWithLinks
from linkUtils
to identify, 'prettify', and correctly mark up both links and email addresses as hyperlinks.