-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #773 from alvesjtiago/algolia-search
Algolia search
- Loading branch information
Showing
16 changed files
with
4,441 additions
and
4,504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Algolia Index Update | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "20.x" | ||
|
||
- name: Install pnpm | ||
run: npm install -g pnpm | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Create and upload index | ||
env: | ||
ALGOLIA_APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }} | ||
ALGOLIA_WRITE_API_KEY: ${{ secrets.ALGOLIA_WRITE_API_KEY }} | ||
ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }} | ||
run: pnpm index:docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,9 @@ public/sitemap.xml | |
|
||
# log files | ||
*.log | ||
|
||
# .env files | ||
.env | ||
|
||
# algolia | ||
.algolia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import AlgoliaContext from "@/utils/contexts/AlgoliaContext"; | ||
import React, { ReactNode, useContext, useEffect } from "react"; | ||
import * as aa from "search-insights"; | ||
|
||
export default function ScrollDispatcher({ | ||
children, | ||
}: Readonly<{ | ||
children: ReactNode; | ||
}>) { | ||
const { queryID, objectID } = useContext(AlgoliaContext); | ||
|
||
const onScroll = () => { | ||
const bottom = | ||
Math.ceil(window.innerHeight + window.scrollY) >= | ||
document.documentElement.scrollHeight; | ||
|
||
if (bottom && queryID && objectID) { | ||
aa.default("convertedObjectIDsAfterSearch", { | ||
index: "docs", | ||
eventName: "Converted Search", | ||
queryID: queryID, | ||
objectIDs: [objectID], | ||
}); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
window.addEventListener("scroll", onScroll); | ||
|
||
return () => { | ||
window.removeEventListener("scroll", onScroll); | ||
}; | ||
}, [queryID, objectID]); | ||
|
||
return <div>{children}</div>; | ||
} |
Oops, something went wrong.