Skip to content

Instantly share code, notes, and snippets.

@ryangjchandler
Last active June 23, 2023 08:22
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryangjchandler/c63adfdedfdf014722fbda80fa9e1aa6 to your computer and use it in GitHub Desktop.
Save ryangjchandler/c63adfdedfdf014722fbda80fa9e1aa6 to your computer and use it in GitHub Desktop.
Raycast - Laravel Documentation

Raycast - Laravel Documentation

This script command provides a quick way of searching the Laravel documentation.

It accepts a query and will open the first result in your default browser.

Installation

  1. Begin by creating a ~/.config/raycast/scripts folder if you don't already have one.

  2. Add the laravel.js and package.json file to this folder.

If you already have a package.json in this folder, run npm install open algoliasearch -D instead.

  1. Add the ~/.config/raycast/scripts folder to Raycast

Open Raycast and search for Extensions. Hit Cmd + N and choose "Add Script Directory". Navigate to and choose the ~/.config/raycast/scripts folder.

  1. Open Raycast and type laravel. It should appear as a Script Command.

  2. Hit Enter and you'll be prompted to enter your search query. Type your search and hit enter. The Raycast output window will tell you how many results were found and it'll open the most relevant in your default browser.

#!/usr/bin/env node
import Algolia from 'algoliasearch'
import open from 'open'
// Required parameters:
// @raycast.schemaVersion 1
// @raycast.title Laravel
// @raycast.mode fullOutput
// Optional parameters:
// @raycast.icon 🤖
// @raycast.argument1 { "type": "text", "placeholder": "Search..." }
// Documentation:
// @raycast.description Search the Laravel documentation.
// @raycast.author Ryan Chandler
// @raycast.authorURL https://github.com/ryangjchandler
const client = Algolia('BH4D9OD16A', '7dc4fe97e150304d1bf34f5043f178c4')
const index = client.initIndex('laravel')
const results = await index.search(process.argv.slice(2)[0], {
facetFilters: ['version:8.x'],
hitsPerPage: 5
})
console.log(`Found ${results.nbHits} results.`)
console.log(`Opening ${results.hits[0].url}...`)
open(results.hits[0].url)
{
"private": true,
"type": "module",
"devDependencies": {
"algoliasearch": "^4.10.5",
"open": "^8.2.1"
}
}
@keizah7
Copy link

keizah7 commented Nov 4, 2022

env: node: No such file or directory

Done in 0.02s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment