Closed daniel-thisnow closed 4 years ago
The query-string library that Maizzle uses for this feature is decoding key/values by default.
I could expose that library's configuration so you could set decode: false
.
It would work like this in your config.js
:
urlParameters: {
opts: {
// pass options directly to query-string
decode: false,
},
},
You would then add params in the template as usual, and your urlParameters
in the front matter will be merged with what is defined in config.js
.
The only problem I see here is coming up with a safe name for that opts
object - someone may actually need to have an &opts=...
parameter.
Meanwhile, you can use replaceStrings
and just flat out replace %40
with @
:
// config.js
module.exports = {
// ...
cleanup: {
replaceStrings: {
'%40': '@',
},
},
}
Thanks Cosmin, very kind of you to help me out.
replaceStrings is good enough for me. Stupidly I tried that last night on my quest, but forgot that I was running maizzle serve instead of production.
I was looking at all kinds of regex's without realising that none of it would have any effect. #bubble.
Happy to help! 😊
Note that running maizzle serve
(or maizzle build
for that matter) uses only the config.js
. So, stuff you want to be globally available in the config, no matter if developing locally or for production, can be added to config.js
.
I'll look into exposing those query-string
options to the config these days, will close the issue once we have a solution in place 👍
@daniel-thisnow I made posthtml-url-parameters, which will allow you to pass options to the query-string
library. It'll be used once we migrate to PostHTML templating - for now just use replaceStrings
.
Added in 65c9d45afdb19f490fa311eacd5a1a41bbc504cb, will be available in v1.0.0
.
I am trying to use DotMailer merge tags in Front Matter urlParameters. I am out of my depth as usual. I know @ is a reserved character and needs the right combination of '' and "" to preserve. I understand double quotes encodes, whereas single could preserve.
urlParameters: utm_source: '@date@'
Url outputs.
utm_source=%40date%40
If anyone knows the answer, that would be great. I've been looking at cheerio and htmlparser2 - generally looking through the dependencies hoping to get lucky with some parameters I can override.
Note- research so far "decodeURIComponent('%40')", , { decodeEntities: true }