Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken algolia implementation #152

Closed
gitFoxCode opened this issue Jun 5, 2023 · 5 comments
Closed

Broken algolia implementation #152

gitFoxCode opened this issue Jun 5, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@gitFoxCode
Copy link

Version

@nuxtjs/algolia: ^1.3.1
nuxt: ^3.5.2

Reproduction Link

https://content.nuxtjs.org/

Steps to reproduce

Use docus docsearch.ts:
https://github.com/nuxt-themes/docus/blob/f56cd8d66441f7a60ad19a8644656c925f9f1747/app/integrations/docsearch.ts#L4

What is Expected?

Working search engine

What is actually happening?

entry.9c90eddd.js:7 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'facetFilters')

When click:

TypeError: Cannot read properties of null (reading 'click')
@gitFoxCode gitFoxCode added the bug Something isn't working label Jun 5, 2023
@Baroshem
Copy link
Collaborator

Baroshem commented Jun 5, 2023

Hey,

I dont have that much experience with Nuxt Content but it seems that the implementation of the DocSearch there is not correct.

In order to make it work properly, there should these two envs passed:

algolia: {
    docSearch: {
      indexName: process.env.ALGOLIA_DOCSEARCH_INDEX_NAME ?? 'indexName',
      facetFilters: process.env.ALGOLIA_DOCSEARCH_FACET_FILTERS ?? ''
    },
}

While I was not able to see them there.

I will talk to the Content guys about it.

@gitFoxCode
Copy link
Author

@Baroshem
I noticed that "userOptions" doesn't work as expected, so I hard-coded the data, and now you can click on the search engine but when typing, this error appears:
image

@Baroshem
Copy link
Collaborator

Baroshem commented Jun 5, 2023

It seems that the variables were not properly set as I have explained above :)

Let's wait for the content guys response

@gitFoxCode
Copy link
Author

I solved this problem, useRuntimeConfig() contains an object, "public", just refer to it
https://github.com/nuxt-themes/docus/blob/f56cd8d66441f7a60ad19a8644656c925f9f1747/app/integrations/docsearch.ts#L23
from:
const { algolia } = useRuntimeConfig()
to:
const { algolia } = useRuntimeConfig().public

@Baroshem
Copy link
Collaborator

Baroshem commented Jun 5, 2023

Ok thanks for letting me know about the result :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants