sveltia / sveltia-cms

Alternative to Netlify/Decap CMS. Fast, lightweight, Git-based headless CMS. Modern UX, first-class i18n support, open source & free. Made with Svelte.
MIT License
819 stars 38 forks source link

Relation widget `value_field` with string templates gets saved with brackets #23

Closed frankbits closed 1 year ago

frankbits commented 1 year ago

"{{route}}#{{sections.*.id}}" still not working. gets saved with the {{}} ({{/}}#{{about-me}})

Originally posted by @frankbits in https://github.com/sveltia/sveltia-cms/issues/19#issuecomment-1574907915

This also breaks how the current data is shown in the sveltia-UI after reopening the saved collection

kyoshino commented 1 year ago

Will check.

kyoshino commented 1 year ago

Well, I didn’t include the template support for value_field because it’s not mentioned in the Relation widget document other than {{slug}}, but I’ll see if it can be done.

frankbits commented 1 year ago

Ah ok... but for my use-case it's needed there... thanks for looking into it

frankbits commented 1 year ago

Isn't only the {{}} missing in the values-replace?

src/lib/components/contents/details/widgets/relation/helper.js:92

labels[valueIndex] = labels[valueIndex].replaceAll(`{{${key}.${k}}}`, v);
values[valueIndex] = values[valueIndex].replaceAll(`${key}.${k}`, v);
frankbits commented 1 year ago

I mean, the String-Template in value-field does get replaced correctly apart from the {{}}, so it is already mostly included...

kyoshino commented 1 year ago

Deployed the fix 🚢

kyoshino commented 1 year ago

Thanks for testing!