You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the where function is a concise way to filter a collection by comparing exact matches between the collections’ data and known values. However, there’s no way to filter it to contain non-exact matches, such as substring, regex, or other types of matches.
One use-case: on my website, I have a data template containing Webmentions (a type of decentralized commenting) for my entire site. Each Webmention has a target URL. I insert Webmentions whose target URL matches the current page, so that each page can end with its own comments section.
I used to use a where filter to select just the mentions whose targets match the canonical URL of the current page; however, this didn’t account for fragments. I wanted the fragments at the end of a target URL to be ignored during comparison. where doesn’t support operators regular expressions, substring matching, or URL parsing. I had to resort to iteration and appending. Here’s a diff containing that change: Seirdy/seirdy.one@6fc55df (plaintext).
Currently, the
where
function is a concise way to filter a collection by comparing exact matches between the collections’ data and known values. However, there’s no way to filter it to contain non-exact matches, such as substring, regex, or other types of matches.One use-case: on my website, I have a data template containing Webmentions (a type of decentralized commenting) for my entire site. Each Webmention has a target URL. I insert Webmentions whose target URL matches the current page, so that each page can end with its own comments section.
I used to use a
where
filter to select just the mentions whose targets match the canonical URL of the current page; however, this didn’t account for fragments. I wanted the fragments at the end of a target URL to be ignored during comparison.where
doesn’t support operators regular expressions, substring matching, or URL parsing. I had to resort to iteration and appending. Here’s a diff containing that change: Seirdy/seirdy.one@6fc55df (plaintext).Discussed on discourse.gohugo.io
The text was updated successfully, but these errors were encountered: