gridsome-plugin-flexsearch icon indicating copy to clipboard operation
gridsome-plugin-flexsearch copied to clipboard

Support function in autoFetch

Open louis-l opened this issue 3 years ago • 3 comments

I try to keep everything as is, and only support function for now. Because I cant think of a solid way to support both normal string and regex string without introducing too much headaches. Also I use both to and from params from afterEach() so we can have more flexibilities when writing the autoFetch() function.

louis-l avatar Oct 19 '21 21:10 louis-l

Thanks @louis-l - have you tested this out by building the Gridsome site in production mode, and deploying it? I'm not sure whether this implementation will work, due to the fact that Gridsome passes the options to the client as a JSON object, so anything like functions will be stripped out.

We should be able to support regex though, as long as it is wrapped in quotes, then passed to .match. We will also need to add a new option (like autoFetchRegex) otherwise it will count as a string and match the if (typeof autoFetch === 'string' || typeof autoFetch === 'object') check.

travis-r6s avatar Oct 21 '21 11:10 travis-r6s

Thanks @thetre97,

I have not tested it in production, but you are right. I have updated to use autoFetchRegex instead.

louis-l avatar Oct 21 '21 21:10 louis-l

Nice - LGTM! I'll check it out soon.

travis-r6s avatar Oct 22 '21 16:10 travis-r6s