Skip to content

Commit

Permalink
refactor: add default replacements for safeClassNames
Browse files Browse the repository at this point in the history
  • Loading branch information
cossssmin committed Oct 13, 2022
1 parent 9de9c7f commit 3815cd1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/transformers/filters/index.js
Expand Up @@ -29,7 +29,12 @@ module.exports = async (html, config = {}, direct = false) => {
]

if (get(config, 'safeClassNames') !== false) {
posthtmlPlugins.push(safeClassNames())
posthtmlPlugins.push(safeClassNames({
replacements: {
'{': '{',
'}': '}'
}
}))
}

return posthtml(posthtmlPlugins)
Expand Down
5 changes: 4 additions & 1 deletion src/transformers/safeClassNames.js
Expand Up @@ -19,7 +19,10 @@ module.exports = async (html, config = {}, direct = false) => {
}

const posthtmlOptions = merge(defaultConfig, get(config, 'build.posthtml.options', {}))
const replacements = direct ? config : get(config, 'safeClassNames', {})
const replacements = direct ? config : get(config, 'safeClassNames', {
'{': '{',
'}': '}'
})

return posthtml([safeClassNames({replacements})]).process(html, posthtmlOptions).then(result => result.html)
}

0 comments on commit 3815cd1

Please sign in to comment.