Implement DocSearch in Quick Actions Modal #1432
JonnyBurger posted onGitHub
š This issue is part of our Hacktoberfest campaign! š Read more about Hacktoberfest here ā²ļø This issue is currently assigned to @uragirii! š° Thanks to CodeChem for sponsoring this issue!
I have implemented a Quick Switcher for Remotion, that can be invoked with Cmd+K / Ctrl+K:
<img width="1466" alt="image" src="https://user-images.githubusercontent.com/1629785/197333403-10f853f0-a4de-4990-a4d4-f34f3f394122.png">
It currently imports two modes:
- If you enter a string, it shows a list of compositions that match this query.
- If you enter a string and prefix it with
"> "
, it shows actions that can be taken from a menu:
<img width="626" alt="image" src="https://user-images.githubusercontent.com/1629785/197333499-381459dd-886f-477c-bf77-e876c46d71cd.png">
This task is about implementing a third mode that allows you to find a Documentation page for Remotion.
The following request:
const query = "spring"
await fetch(
'https://plsduol1ca-dsn.algolia.net/1/indexes/*/queries?x-algolia-agent=' +
encodeURIComponent('Remotion Preview DocSearch') +
'&x-algolia-api-key=3e42dbd4f895fe93ff5cf40d860c4a85&x-algolia-application-id=PLSDUOL1CA',
{
headers: {
'content-type': 'application/x-www-form-urlencoded',
},
body: JSON.stringify({
requests: [
{
query,
indexName: 'remotion',
params:
'attributesToRetrieve=["hierarchy.lvl0","hierarchy.lvl1","hierarchy.lvl2","hierarchy.lvl3","hierarchy.lvl4","hierarchy.lvl5","hierarchy.lvl6","content","type","url"]&attributesToSnippet=["hierarchy.lvl1:10","hierarchy.lvl2:10","hierarchy.lvl3:10","hierarchy.lvl4:10","hierarchy.lvl5:10","hierarchy.lvl6:10","content:10"]&snippetEllipsisText=ā¦&highlightPreTag=<mark>&highlightPostTag=</mark>&hitsPerPage=20&facetFilters=[]',
},
],
}),
method: 'POST',
}
).then((res) => res.json());
will return documentation results for spring
.
Acceptance criteria
- Implement a third mode in the Quick Actions modal to find documentation pages based on a query. It does not have to support nesting as Algolia DocSearch, but you can take inspiration from it:
<img width="683" alt="image" src="https://user-images.githubusercontent.com/1629785/197334198-88eb9d0f-609f-42a0-8464-825c73a11f0f.png">
- Do not introduce new dependencies, keep it minimalistic and rather have fewer features than introduce much complexity
- Make it so that you can prefix any query with
"? "
to switch to the DocSearch mode, similar to how you can enter>
to search for Actions.