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

fix: make Algolia Search work out-of-the-box #348

Merged
merged 2 commits into from
Nov 9, 2021

Conversation

seqre
Copy link
Contributor

@seqre seqre commented Nov 9, 2021

I recently created my own website using the LoveIt theme and moved to DoIt shortly after. I wanted to set up Algolia Search for it, managed to send indices to Algolia, search for entries, but every time I would click on the entry it would redirect me to /undefined/.

After a lot of digging, I figured out that the Javascript code in theme.js is not specifying the attributes it needs in attributesToRetrieve, which are not sent by Algolia by default (those can be sent, but it needs to be changed in the configuration of Algolia Search indices) making the URI not available.

I believe that setting that value in the search would make the search function work out-of-the-box for all users. The diff looks bad because it's minified file, but the change boils down to adding the attributesToRetrieve entry.

window._algoliaIndex
    .search(b, {
        offset: 0,
        length: 8 * c,
        attributesToRetrieve: ["title", "content", "date", "uri"],
        attributesToHighlight: ["title"],
        attributesToSnippet: ["content:".concat(d)],
        highlightPreTag: "<".concat(e, ">"),
        highlightPostTag: "</".concat(e, ">"),
    })

@vercel
Copy link

vercel bot commented Nov 9, 2021

Someone is attempting to deploy a commit to a Personal Account owned by @HEIGE-PCloud on Vercel.

@HEIGE-PCloud first needs to authorize it.

@HEIGE-PCloud
Copy link
Owner

image

The attributesToRetrieve can be set in the dashboard as well, and by default, everything is returned, so technically it should work out-of-the-box...

But I agree with you that setting the value explicitly in theme.js can prevent some issues...

@vercel
Copy link

vercel bot commented Nov 9, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pcloud/do-it/2t3Lx8VdoopM3Gjh8wVXPuijAe4v
✅ Preview: https://do-it-git-fork-seqre-main-pcloud.vercel.app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants