-
Notifications
You must be signed in to change notification settings - Fork 7
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
Upgrade JS dependencies to latest versions #66
Changes from all commits
25c22cc
b28c479
68d1c43
e1a9f0c
b583268
1ba0e08
78b71fa
605a037
06060f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,10 +23,8 @@ const WorkflowCard = ({ workflow, isSearchResult }: WorkflowCardProps) => { | |
|
||
// Be default we should use the <a> tag for the cards so search crawlers can find the URLs. | ||
const LinkCard = ({ children }: { children: React.ReactNode }) => ( | ||
<Link href={destination}> | ||
<a className={CARD_STYLE} onClick={trackClick}> | ||
{children} | ||
</a> | ||
<Link href={destination} className={CARD_STYLE} onClick={trackClick}> | ||
{children} | ||
Comment on lines
-26
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
</Link> | ||
); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,21 @@ | ||
import { connectStateResults } from "react-instantsearch-dom"; | ||
import { SearchState, SearchResults } from "react-instantsearch-core"; | ||
import { useInstantSearch } from 'react-instantsearch'; | ||
import { WorkflowCards } from "../WorkflowCard"; | ||
import { Workflow } from "warp-workflows"; | ||
|
||
function Hits({ | ||
searchState, | ||
searchResults, | ||
children, | ||
}: { | ||
searchState: SearchState; | ||
searchResults: SearchResults; | ||
children: React.ReactNode; | ||
}) { | ||
if (!searchState.query || searchState.query.length == 0) { | ||
function Hits({ children }: { children: React.ReactNode }) { | ||
const { results } = useInstantSearch(); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (!results.query || results.query.length == 0) { | ||
return <>{children}</>; | ||
} else if (searchResults?.hits.length > 0) { | ||
const workflows: Workflow[] = searchResults!.hits.map( | ||
} else if (results?.hits.length > 0) { | ||
const workflows: Workflow[] = results!.hits.map( | ||
({ slug, name, description, tags }) => | ||
({ | ||
slug, | ||
name, | ||
description, | ||
tags: Array.isArray(tags) ? tags : [tags], | ||
} as Workflow) | ||
({ | ||
slug, | ||
name, | ||
description, | ||
tags: Array.isArray(tags) ? tags : [tags], | ||
} as Workflow) | ||
); | ||
return <WorkflowCards workflows={workflows} isSearchResults={true} />; | ||
} else { | ||
|
@@ -39,4 +32,4 @@ function Hits({ | |
} | ||
} | ||
|
||
export default connectStateResults(Hits); | ||
export default Hits; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { connectSearchBox } from "react-instantsearch-dom"; | ||
import { useSearchBox } from 'react-instantsearch'; | ||
import { Dispatch, SetStateAction, useEffect, useState } from "react"; | ||
import { SearchIcon } from "../icons/search"; | ||
import { useHotkeys } from "react-hotkeys-hook"; | ||
import { useRouter } from "next/router"; | ||
|
||
function SearchBox({ refine }: { refine: Dispatch<SetStateAction<string>> }) { | ||
interface SearchBoxProps { | ||
refine: Dispatch<SetStateAction<string>>; | ||
} | ||
|
||
function SearchBox({ refine }: SearchBoxProps) { | ||
let [searchBarState, setSearchBarState] = useState(""); | ||
useHotkeys("ctrl+k", () => { | ||
if (document != null) { | ||
|
@@ -44,4 +48,14 @@ function SearchBox({ refine }: { refine: Dispatch<SetStateAction<string>> }) { | |
); | ||
} | ||
|
||
function connectSearchBox(Component: any) { | ||
const SearchBox = (props: any) => { | ||
const data = useSearchBox(props); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar story here - |
||
return <Component {...props} {...data} />; | ||
}; | ||
|
||
return SearchBox; | ||
} | ||
|
||
export default connectSearchBox(SearchBox); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// It is run whenever the next js project is built. (It is called with the `postbuild` command in package.json.) | ||
// Reference: https://www.contentful.com/blog/2021/07/02/add-algolia-instantsearch-to-nextjs-app/ | ||
import * as dotenv from "dotenv"; | ||
import algoliasearch from "algoliasearch"; | ||
import { algoliasearch } from "algoliasearch"; | ||
import { getSortedWorkflowsData } from "./workflows"; | ||
|
||
(async function () { | ||
|
@@ -32,23 +32,20 @@ import { getSortedWorkflowsData } from "./workflows"; | |
process.env.ALGOLIA_SEARCH_ADMIN_KEY! | ||
); | ||
|
||
// Initialize the index with the algolia index name we set up | ||
const index = client.initIndex("workflow_specs"); | ||
|
||
const indexName = "workflow_specs"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In version 4 of |
||
|
||
// Clear all objects before rewriting to remove specs that were deleted | ||
// from the Algolia index. | ||
index.clearObjects(); | ||
client.clearObjects({ indexName }); | ||
|
||
// Save the objects | ||
const algoliaResponse = await index.saveObjects(transformed); | ||
|
||
console.log( | ||
`🎉 Sucessfully added ${ | ||
algoliaResponse.objectIDs.length | ||
} records to Algolia search. Object IDs:\n${algoliaResponse.objectIDs.join( | ||
"\n" | ||
)}` | ||
); | ||
const algoliaResponse = await client.saveObjects({ indexName, objects: transformed }); | ||
|
||
const objectIdsAdded = algoliaResponse.reduce<string[]>((acc, response) => { | ||
return acc.concat(response.objectIDs); | ||
}, []); | ||
|
||
console.log(`🎉 Sucessfully added ${objectIdsAdded.length} records to Algolia search. Object IDs:\n${objectIdsAdded.join("\n")}`); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little bizarre - CI specified 17.x, but our Vercel deployment was still using 14.x (it doesn't even support non-LTS versions). Now, they're both using 20.x.