Skip to content

Commit 47549f6

Browse files
committed
improves hierarchy display text
1 parent c01ab05 commit 47549f6

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
An ultra-fast VueJS docs search workflow for Alfred 3.
44

5-
Adapted from [Alfred Laravel Docs](https://github.com/tillkruss/alfred-laravel-docs), Thanks [Till Krüss](https://github.com/tillkruss)!
5+
Adapted from [Alfred Laravel Docs](https://github.com/tillkruss/alfred-laravel-docs), Thanks [Till Krüss](https://twitter.com/tillkruss)!
66

77
![Screenshot](screenshot.png)
88

99
## Installation
1010

11-
1. [Download the latest version](https://github.com/vmitchell85/alfred-vuejs-docs/releases/download/0.1/VueJS.Docs.alfredworkflow)
11+
1. [Download the latest version](https://github.com/vmitchell85/alfred-vuejs-docs/releases/download/0.1.1/VueJS.Docs.alfredworkflow)
1212
2. Install the workflow by double-clicking the `.alfredworkflow` file
1313
3. You can add the workflow to a category, then click "Import" to finish importing. You'll now see the workflow listed in the left sidebar of your Workflows preferences pane.
1414

Diff for: vuejs.php

+20-19
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
require __DIR__ . '/vendor/autoload.php';
88

99
$query = $argv[1];
10-
$branch = empty($_ENV['branch']) ? 'master' : $_ENV['branch'];
1110

1211
$workflow = new Workflow;
1312
$algolia = new Algolia('BH4D9OD16A', '85cc3221c9f23bfbaa4e3913dd7625ea');
1413

15-
AlgoliaUserAgent::addSuffixUserAgentSegment('Alfred Workflow', '0.2.1');
14+
AlgoliaUserAgent::addSuffixUserAgentSegment('VueJS Alfred Workflow', '0.1.1');
1615

1716
$index = $algolia->initIndex('vuejs');
1817
$search = $index->search($query, ['facetFilters' => 'version:v2']);
@@ -22,7 +21,7 @@
2221
$workflow->result()
2322
->title('No matches')
2423
->icon('google.png')
25-
->subtitle("No match found in the docs. Search Google for: \"{$query}\"")
24+
->subtitle("No match found in the docs. Search Google for: \"VueJS+{$query}\"")
2625
->arg("https://www.google.com/search?q=vuejs+{$query}")
2726
->quicklookurl("https://www.google.com/search?q=vuejs+{$query}")
2827
->valid(true);
@@ -32,24 +31,26 @@
3231
}
3332

3433
foreach ($results as $hit) {
35-
$hasText = isset($hit['_highlightResult']['content']['value']);
36-
$hasSubtitle = isset($hit['h2']);
37-
38-
$title = $hit['h1'];
39-
$subtitle = $hasSubtitle ? $hit['h2'] : null;
40-
41-
if ($hasText) {
42-
$subtitle = $hit['_highlightResult']['content']['value'];
43-
44-
if ($hasSubtitle) {
45-
$title = "{$title} » {$hit['h2']}";
46-
}
34+
$highestLvl = $hit['hierarchy']['lvl6'] ? 6 : (
35+
$hit['hierarchy']['lvl5'] ? 5 : (
36+
$hit['hierarchy']['lvl4'] ? 4 : (
37+
$hit['hierarchy']['lvl3'] ? 3 : (
38+
$hit['hierarchy']['lvl2'] ? 2 : (
39+
$hit['hierarchy']['lvl1'] ? 1 : 0
40+
)
41+
)
42+
)
43+
)
44+
);
45+
46+
$title = $hit['hierarchy']['lvl' . $highestLvl];
47+
$currentLvl = 0;
48+
$subtitle = $hit['hierarchy']['lvl0'];
49+
while ($currentLvl < $highestLvl) {
50+
$currentLvl = $currentLvl + 1;
51+
$subtitle = $subtitle . ' » ' . $hit['hierarchy']['lvl' . $currentLvl];
4752
}
4853

49-
$title = $hit['hierarchy']['lvl6'] ?: $hit['hierarchy']['lvl5'] ?: $hit['hierarchy']['lvl4'] ?: $hit['hierarchy']['lvl2'] ?: $hit['hierarchy']['lvl1'] ?: $hit['hierarchy']['lvl0'];
50-
51-
$subtitle = $hit['hierarchy']['lvl0'] . ($hit['hierarchy']['lvl1'] ? ' => ' . $hit['hierarchy']['lvl1'] : '');
52-
5354
$workflow->result()
5455
->uid($hit['objectID'])
5556
->title($title)

0 commit comments

Comments
 (0)