Releases: travis-r6s/gridsome-plugin-flexsearch
V2 - Internal GraphQL refactor
TLDR: While this release has had some fairly major internal refactoring, no major user functionality has really changed. Please note that path
is no longer automatically available in your search result.
Internal update to use GraphQL
The code has been changed to use Gridsome's internal graphql
function - this brings a number of benefits, including automatically resolving & fetching referenced data, local (built) image paths, and using the internal schema so any custom resolvers are picked up.
Deprecations
As the plugin now uses the internal graphql
function, no node fields will be automatically added to your search result. This means that the path
field (which was automatically added if available in version 1) will need to be specifically added to your collection fields.
collections: [
{
typeName: "post",
indexName: "post",
+ fields: ["title", "description", "heroImage", "path"],
},
]
You can access it in the search result as with any other field: <g-link :to="searchResult.node.path"></g-link>
This release drops support for fetching data from remote schemas. The main reason for this being that you probably shouldn't use them anyway 🙃 - it brings quite a few difficulties that Gridsome's internals are meant to solve - for example, if you wanted to use this with WP GraphQL, it would be too complicated for this plugin to sort GraphQL pagination, so you would only ever get the first 100 results from any custom query.
Version 1
This version 1.0.0 release has a few updates that will most likely encur breaking changes to sites, hence the major version bump. These include:
- Moving the docs data under a node key, to avoid fields being stringified or otherwise manipulated if needed as a search field, to fix #38
- Changing the ID to use a generated uuid, to fix #34
- Add optional compression to fix #39
It also requires the latest version of Gridsome (v0.7.15 at time of writing) as it uses the onBootstrap
hook to fetch data after the store has loaded, instead of using the onCreateNode
hook. Using the onCreateNode
hook could cause problems as this plugin didn't necessarily run last in the chain, meaning the node wouldn't have any manual updates made in another onCreateNode
hook.
Code Changes
The search result now returns a node
object containing the fields
data you specified, so you should now use that object for any data you are using in your templates instead of the top level keys. This is because those keys might be used in the search index and transformed in someway - i.e. if you added a tags
array as a search field, this plugin would stringify that array to conform with FlexSearch's current requirements for searching through arrays. Because of that, the search result would return the array as a string. See #38 for an example.
Example changes below:
Before
<g-link
v-for="result in searchResults"
:key="result.id"
:to="result.path"
class="navbar-item">
{{ result.title }}
</g-link>
After
// Destructure returned result and alias result to the node key. If using path, you will also need to destructure that.
<g-link
v-for="({ node: result, path }) in searchResults"
:key="result.id"
:to="path"
class="navbar-item">
{{ result.title }}
</g-link>
Or:
// Destructure returned result and alias result to the node key. If using path, you will also need to destructure that.
<g-link
v-for="result in searchResults"
:key="result.node.id"
:to="result.path"
class="navbar-item">
{{ result.node.title }}
</g-link>
Version 0.1.20 - Potential breaking release
This release updated the core-js
version to v3
, and removes regenerator-runtime
. These were needed to compile correctly in Gridsome versions < 0.1.4
; so if you are upgrading to this release, you should also make sure your gridsome
package is at least v0.7.14
.