decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.81k stars 3.04k forks source link

Custom preview dynamic css file #4364

Closed henval2020 closed 1 year ago

henval2020 commented 3 years ago

** Feature

Would it be possible if there would be multiple templates like this one (from one-click-hugo-cms) image

To have their own respective css. Right now it was implemented like this CMS.registerPreviewStyle(styles, { raw: true }); Where it can only use one CSS for all templates.

So if we use the same class name on different templates, they would have different styling.

erezrokah commented 3 years ago

Thanks for reporting @henval2020, since we're passing the frame window and document as props: https://www.netlifycms.org/docs/customization/#registerpreviewtemplate

Could you dynamically add the styles in each component?

See an example here: https://github.com/netlify/netlify-cms/issues/4142#issuecomment-674505811 https://github.com/erezrokah/netlify-cms-reproductions/blob/d9300a4e970aa47dc4ec2054e7f30a0f85ae3796/public/index.html#L13

for scripts. You should be able to do the same with styles.

martinjagodic commented 1 year ago

Closing as stale and/or outdated.