Home
Support Forums

How to get variable set by netlifycms in plugin or function

Is it possible to use content generated by netlifycms within a plugin or function? I want to set a boolean value from netlifycms and use this in a function. I read on this forum that a function cannot read a variable or content outside it’s folder. Therefor I want to write a file in this directory with the help of a plugin. The plugin can read content generated by the netlify build, but not the JSON-files generates by the cms, as far as I know. How can I do this?

Hey @_william,
I would start with our Build Plugin docs:

The workflow you’re describing isn’t totally clear to me but it sounds like you will want to write a plugin that hooks into onBuild since that is after your site builds (so, your new CMS files) but before your function builds. So you’ll grep through your built files to find whatever boolean you set and then inject it into a function somehow. I don’t know of a build plugin that does anything like this yet, so we’d love to hear what your final result is like!