Pass Data in matter() Option
pxwee5 opened this issue · 1 comments
pxwee5 commented
Is there a way to pass global data or other kinds of data e.g. required() data in an object into the option field? That way we can just reference it like
---
images:
small: {{image.mobile.src}}
medium: {{image.tablet.src}}
large: {{image.desktop.src}}
---
The object is supplied in another javascript code with
const image = require('hello.jpg?resize=500,100,1500')
doowb commented
This package (gray-matter
) does not do anything with those values in the front matter. It just parses the front matter from the contents passed in and turns it into an object. This means your .data
property will look like this:
{
images: {
small: '{{image.mobile.src}}',
medium: '{{image.tablet.src}}',
large: '{{image.desktop.src}}'
}
You can use something else, like expand to ... expand those values.