|
6 | 6 | SELECT 'redirect' as component, $redirect as link WHERE $redirect IS NOT NULL;
|
7 | 7 |
|
8 | 8 |
|
9 |
| -select 'dynamic' as component, properties FROM example WHERE component = 'shell' LIMIT 1; |
| 9 | +select 'dynamic' as component, json_patch(json_extract(properties, '$[0]'), json_object( |
| 10 | + 'title', coalesce($search || ' | ', '') || 'SQLPage documentation search' |
| 11 | +)) as properties |
| 12 | +FROM example WHERE component = 'shell' LIMIT 1; |
10 | 13 |
|
11 | 14 | SELECT 'form' as component,
|
12 | 15 | 'GET' as method,
|
@@ -37,45 +40,69 @@ WHERE $search IS NOT NULL;
|
37 | 40 |
|
38 | 41 | WITH search_results AS (
|
39 | 42 | SELECT
|
| 43 | + COALESCE( |
| 44 | + component_name || ' component: parameter ' || parameter_name |
| 45 | + , component_name || ' component' || IF(component_example_description IS NULL, '', ' example') |
| 46 | + , 'blog: ' || blog_title |
| 47 | + , 'sqlpage.' || function_name || '(...' || function_parameter_name || '...)' |
| 48 | + , 'sqlpage.' || function_name || '(...)' |
| 49 | + ) as title, |
| 50 | + COALESCE( |
| 51 | + component_description, |
| 52 | + parameter_description, |
| 53 | + blog_description, |
| 54 | + function_parameter_description, |
| 55 | + function_description, |
| 56 | + component_example_description |
| 57 | + ) as description, |
40 | 58 | CASE
|
41 |
| - WHEN parameter_name IS NOT NULL THEN component_name || ' component: parameter ' || parameter_name |
42 |
| - WHEN component_name IS NOT NULL THEN component_name || ' component' |
43 |
| - WHEN blog_title IS NOT NULL THEN 'blog: ' || blog_title |
44 |
| - WHEN function_parameter_name IS NOT NULL THEN function_name || '(...' || function_parameter_name || '...)' |
45 |
| - WHEN function_name IS NOT NULL THEN function_name || '(...)' |
46 |
| - END as title, |
47 |
| - CASE |
48 |
| - WHEN component_description IS NOT NULL THEN component_description |
49 |
| - WHEN parameter_description IS NOT NULL THEN parameter_description |
50 |
| - WHEN blog_description IS NOT NULL THEN blog_description |
51 |
| - WHEN function_description IS NOT NULL THEN function_description |
52 |
| - WHEN function_parameter_description IS NOT NULL THEN function_parameter_description |
53 |
| - END as description, |
54 |
| - CASE |
55 |
| - WHEN component_name IS NOT NULL THEN json_object('page', '/component.sql', 'parameters', json_object('component', component_name)) |
56 |
| - WHEN parameter_name IS NOT NULL THEN json_object('page', '/component.sql', 'parameters', json_object('component', ( |
57 |
| - SELECT component FROM parameter |
58 |
| - WHERE name = parameter_name |
59 |
| - LIMIT 1 |
60 |
| - ))) |
61 |
| - WHEN blog_title IS NOT NULL THEN json_object('page', '/blog.sql', 'parameters', json_object('post', blog_title)) |
62 |
| - WHEN function_name IS NOT NULL THEN json_object('page', '/functions.sql', 'parameters', json_object('function', function_name)) |
63 |
| - WHEN function_parameter_name IS NOT NULL THEN json_object('page', '/functions.sql', 'parameters', json_object('function', ( |
64 |
| - SELECT function FROM sqlpage_function_parameters |
65 |
| - WHERE name = function_parameter_name |
66 |
| - LIMIT 1 |
67 |
| - ))) |
| 59 | + WHEN component_name IS NOT NULL THEN |
| 60 | + json_object( |
| 61 | + 'page', '/component.sql', |
| 62 | + 'parameters', json_object('component', component_name) |
| 63 | + ) |
| 64 | + WHEN parameter_name IS NOT NULL THEN |
| 65 | + json_object( |
| 66 | + 'page', '/component.sql', |
| 67 | + 'parameters', json_object('component', ( |
| 68 | + SELECT component |
| 69 | + FROM parameter |
| 70 | + WHERE name = parameter_name |
| 71 | + LIMIT 1 |
| 72 | + )) |
| 73 | + ) |
| 74 | + WHEN blog_title IS NOT NULL THEN |
| 75 | + json_object( |
| 76 | + 'page', '/blog.sql', |
| 77 | + 'parameters', json_object('post', blog_title) |
| 78 | + ) |
| 79 | + WHEN function_name IS NOT NULL THEN |
| 80 | + json_object( |
| 81 | + 'page', '/functions.sql', |
| 82 | + 'parameters', json_object('function', function_name) |
| 83 | + ) |
| 84 | + WHEN function_parameter_name IS NOT NULL THEN |
| 85 | + json_object( |
| 86 | + 'page', '/functions.sql', |
| 87 | + 'parameters', json_object('function', ( |
| 88 | + SELECT function |
| 89 | + FROM sqlpage_function_parameters |
| 90 | + WHERE name = function_parameter_name |
| 91 | + LIMIT 1 |
| 92 | + )) |
| 93 | + ) |
68 | 94 | END as link_data,
|
69 | 95 | rank
|
70 | 96 | FROM documentation_fts
|
71 | 97 | WHERE $search IS NOT NULL
|
72 | 98 | AND documentation_fts = $search
|
73 | 99 | )
|
74 | 100 | SELECT
|
75 |
| - title, |
76 |
| - description, |
| 101 | + max(title) as title, |
| 102 | + max(description) as description, |
77 | 103 | sqlpage.link(link_data->>'page', link_data->'parameters') as link
|
78 | 104 | FROM search_results
|
| 105 | +GROUP BY link_data |
79 | 106 | ORDER BY
|
80 | 107 | rank,
|
81 | 108 | CASE
|
|
0 commit comments