-
Notifications
You must be signed in to change notification settings - Fork 4
/
tailwindcss.php
executable file
·53 lines (39 loc) · 1.46 KB
/
tailwindcss.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
use Alfred\Workflows\Workflow;
use Algolia\AlgoliaSearch\SearchClient as Algolia;
use Algolia\AlgoliaSearch\Support\UserAgent as AlgoliaUserAgent;
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/functions.php';
$query = $argv[1];
$workflow = new Workflow;
//$algolia = Algolia::create('R90K1756AM', 'a6e52654d6b591febdf42b07e0e7374a');
$algolia = Algolia::create('KNPXZI5B0M', '5fc87cef58bb80203d2207578309fab6');
AlgoliaUserAgent::addCustomUserAgent('TailwindCSS Alfred Workflow', '3.0.1');
$results = getResults($algolia, 'tailwindcss', $query, ['facetFilters' => 'version:v3']);
if (empty($results)) {
$workflow->result()
->title('No matches')
->icon('google.png')
->subtitle("No match found in the docs. Search Google for: \"TailwindCSS+{$query}\"")
->arg("https://www.google.com/search?q=tailwindcss+{$query}")
->quicklookurl("https://www.google.com/search?q=tailwindcss+{$query}")
->valid(true);
echo $workflow->output();
exit;
}
foreach ($results as $hit) {
list($title, $titleLevel) = getTitle($hit);
if ($title === null) {
continue;
}
$title = html_entity_decode($title);
$workflow->result()
->uid($hit['objectID'])
->title($title)
->autocomplete($title)
->subtitle(html_entity_decode(getSubtitle($hit, $titleLevel)))
->arg($hit['url'])
->quicklookurl($hit['url'])
->valid(true);
}
echo $workflow->output();