I’m trying to filter posts based on tags and some of my tags contain special characters like ‘:’, ‘=’ or ‘•’. Therefore, using these tags with the #get helper results in a blank template.
I’ve tried with no luck… When doing so, the helper will default to the else block in the following snippet.
{{#get "posts" limit="3" include="tags" filter="tags:'type=hike'"}}
{{#foreach posts}}
...
{{else}}
<div>
<p class="font-semibold">No posts for now. Come back soon!</p>
</div>
{{/foreach}}
{{/get}}
I’ve also tried the following : {{#get "posts" limit="3" include="tags" filter='tags:"type=hike"'}}
and {{#get "posts" limit="3" include="tags" filter="tags:type\=hike"}}
Aaah! Slugs are in fact escaped. I’ve done a little bit of research and it turns out that all special characters are replaced with a dash.
Found this snippet of code in ‘slugify.js’ from the @tryghost/string package :
// Replace URL reserved chars: `@:/?#[]!$&()*+,;=` as well as `\%<>|^~£"{}` and \`
string = string.replace(/(\s|\.|@|:|\/|\?|#|\[|\]|!|\$|&|\(|\)|\*|\+|,|;|=|\\|%|<|>|\||\^|~|"|\{|\}|`|–|—)/g, '-')
// Remove apostrophes
.replace(/'/g, '')
// Make the whole thing lowercase
.toLowerCase();
So I guess the solution is to only use ‘-’ in tags. Thanks for your help!