ransack 3.1.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql.yml +72 -0
- data/.github/workflows/test.yml +22 -27
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +79 -0
- data/CONTRIBUTING.md +38 -16
- data/Gemfile +10 -10
- data/README.md +8 -13
- data/bug_report_templates/test-ransacker-arel-present-predicate.rb +4 -0
- data/docs/docs/getting-started/advanced-mode.md +1 -1
- data/docs/docs/getting-started/search-matches.md +1 -1
- data/docs/docs/getting-started/simple-mode.md +30 -26
- data/docs/docs/getting-started/sorting.md +1 -1
- data/docs/docs/going-further/acts-as-taggable-on.md +10 -10
- data/docs/docs/going-further/exporting-to-csv.md +2 -2
- data/docs/docs/going-further/form-customisation.md +1 -1
- data/docs/docs/going-further/i18n.md +3 -3
- data/docs/docs/going-further/other-notes.md +1 -1
- data/docs/docs/going-further/saving-queries.md +1 -1
- data/docs/docs/going-further/searching-postgres.md +1 -1
- data/docs/docs/intro.md +2 -2
- data/docs/docusaurus.config.js +14 -1
- data/docs/package.json +7 -2
- data/docs/yarn.lock +3036 -1917
- data/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +11 -1
- data/lib/ransack/adapters/active_record/base.rb +78 -7
- data/lib/ransack/adapters/active_record/context.rb +17 -49
- data/lib/ransack/configuration.rb +25 -12
- data/lib/ransack/constants.rb +125 -3
- data/lib/ransack/context.rb +34 -5
- data/lib/ransack/helpers/form_builder.rb +3 -3
- data/lib/ransack/helpers/form_helper.rb +4 -3
- data/lib/ransack/nodes/attribute.rb +2 -2
- data/lib/ransack/nodes/condition.rb +80 -7
- data/lib/ransack/nodes/grouping.rb +3 -3
- data/lib/ransack/nodes/node.rb +1 -1
- data/lib/ransack/nodes/value.rb +2 -2
- data/lib/ransack/predicate.rb +1 -1
- data/lib/ransack/ransacker.rb +1 -1
- data/lib/ransack/search.rb +9 -4
- data/lib/ransack/translate.rb +2 -2
- data/lib/ransack/version.rb +1 -1
- data/lib/ransack/visitor.rb +38 -2
- data/lib/ransack.rb +3 -6
- data/ransack.gemspec +2 -2
- data/spec/helpers/polyamorous_helper.rb +2 -8
- data/spec/ransack/adapters/active_record/base_spec.rb +73 -0
- data/spec/ransack/configuration_spec.rb +9 -9
- data/spec/ransack/helpers/form_builder_spec.rb +8 -8
- data/spec/ransack/helpers/form_helper_spec.rb +48 -2
- data/spec/ransack/nodes/condition_spec.rb +24 -0
- data/spec/ransack/nodes/value_spec.rb +115 -0
- data/spec/ransack/predicate_spec.rb +36 -1
- data/spec/ransack/translate_spec.rb +1 -1
- data/spec/support/schema.rb +27 -10
- metadata +11 -19
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +0 -20
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +0 -79
- data/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +0 -11
- data/lib/polyamorous.rb +0 -1
- data/lib/ransack/adapters/active_record/ransack/constants.rb +0 -128
- data/lib/ransack/adapters/active_record/ransack/context.rb +0 -56
- data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +0 -69
- data/lib/ransack/adapters/active_record/ransack/translate.rb +0 -8
- data/lib/ransack/adapters/active_record/ransack/visitor.rb +0 -47
- data/lib/ransack/adapters.rb +0 -64
- data/lib/ransack/nodes.rb +0 -8
- /data/lib/ransack/{adapters/active_record.rb → active_record.rb} +0 -0
@@ -11,7 +11,7 @@ mode should meet your needs.
|
|
11
11
|
|
12
12
|
## In your controller
|
13
13
|
|
14
|
-
```
|
14
|
+
```ruby
|
15
15
|
def index
|
16
16
|
@q = Person.ransack(params[:q])
|
17
17
|
@people = @q.result(distinct: true)
|
@@ -20,13 +20,17 @@ end
|
|
20
20
|
or without `distinct: true`, for sorting on an associated table's columns (in
|
21
21
|
this example, with preloading each Person's Articles and pagination):
|
22
22
|
|
23
|
-
```
|
23
|
+
```ruby
|
24
24
|
def index
|
25
25
|
@q = Person.ransack(params[:q])
|
26
26
|
@people = @q.result.includes(:articles).page(params[:page])
|
27
27
|
end
|
28
28
|
```
|
29
29
|
|
30
|
+
:::caution
|
31
|
+
By default, searching and sorting are authorized on any column of your model. See [Authorization (allowlisting/denylisting)](/going-further/other-notes.md#authorization-allowlistingdenylisting) on how to prevent this.
|
32
|
+
:::
|
33
|
+
|
30
34
|
### Default search options
|
31
35
|
|
32
36
|
#### Search parameter
|
@@ -35,7 +39,7 @@ Ransack uses a default `:q` param key for search params. This may be changed by
|
|
35
39
|
setting the `search_key` option in a Ransack initializer file (typically
|
36
40
|
`config/initializers/ransack.rb`):
|
37
41
|
|
38
|
-
```
|
42
|
+
```ruby
|
39
43
|
Ransack.configure do |c|
|
40
44
|
# Change default search parameter key name.
|
41
45
|
# Default key name is :q
|
@@ -48,9 +52,9 @@ end
|
|
48
52
|
After version 2.4.0 when searching a string query Ransack by default strips all whitespace around the query string.
|
49
53
|
This may be disabled by setting the `strip_whitespace` option in a Ransack initializer file:
|
50
54
|
|
51
|
-
```
|
55
|
+
```ruby
|
52
56
|
Ransack.configure do |c|
|
53
|
-
# Change whitespace stripping
|
57
|
+
# Change whitespace stripping behavior.
|
54
58
|
# Default is true
|
55
59
|
c.strip_whitespace = false
|
56
60
|
end
|
@@ -60,13 +64,13 @@ end
|
|
60
64
|
|
61
65
|
The two primary Ransack view helpers are `search_form_for` and `sort_link`,
|
62
66
|
which are defined in
|
63
|
-
[Ransack::Helpers::FormHelper](https://github.com/activerecord-hackery/ransack/lib/ransack/helpers/form_helper.rb).
|
67
|
+
[Ransack::Helpers::FormHelper](https://github.com/activerecord-hackery/ransack/blob/main/lib/ransack/helpers/form_helper.rb).
|
64
68
|
|
65
69
|
### Form helper
|
66
70
|
|
67
71
|
Ransack's `search_form_for` helper replaces `form_for` for creating the view search form
|
68
72
|
|
69
|
-
```
|
73
|
+
```erb
|
70
74
|
<%= search_form_for @q do |f| %>
|
71
75
|
|
72
76
|
# Search if the name field contains...
|
@@ -95,7 +99,7 @@ search predicates.
|
|
95
99
|
|
96
100
|
The `search_form_for` answer format can be set like this:
|
97
101
|
|
98
|
-
```
|
102
|
+
```erb
|
99
103
|
<%= search_form_for(@q, format: :pdf) do |f| %>
|
100
104
|
|
101
105
|
<%= search_form_for(@q, format: :json) do |f| %>
|
@@ -105,7 +109,7 @@ The `search_form_for` answer format can be set like this:
|
|
105
109
|
|
106
110
|
Ransack's `sort_link` helper creates table headers that are sortable links
|
107
111
|
|
108
|
-
```
|
112
|
+
```erb
|
109
113
|
<%= sort_link(@q, :name) %>
|
110
114
|
```
|
111
115
|
Additional options can be passed after the column parameter, like a different
|
@@ -114,13 +118,13 @@ column title or a default sort order.
|
|
114
118
|
If the first option after the column parameter is a String, it's considered a
|
115
119
|
custom label for the link:
|
116
120
|
|
117
|
-
```
|
121
|
+
```erb
|
118
122
|
<%= sort_link(@q, :name, 'Last Name', default_order: :desc) %>
|
119
123
|
```
|
120
124
|
|
121
125
|
You can use a block if the link markup is hard to fit into the label parameter:
|
122
126
|
|
123
|
-
```
|
127
|
+
```erb
|
124
128
|
<%= sort_link(@q, :name) do %>
|
125
129
|
<strong>Player Name</strong>
|
126
130
|
<% end %>
|
@@ -130,14 +134,14 @@ With a polymorphic association, you may need to specify the name of the link
|
|
130
134
|
explicitly to avoid an `uninitialized constant Model::Xxxable` error (see issue
|
131
135
|
[#421](https://github.com/activerecord-hackery/ransack/issues/421)):
|
132
136
|
|
133
|
-
```
|
137
|
+
```erb
|
134
138
|
<%= sort_link(@q, :xxxable_of_Ymodel_type_some_attribute, 'Attribute Name') %>
|
135
139
|
```
|
136
140
|
|
137
141
|
If the first option after the column parameter and/or the label parameter is an
|
138
142
|
Array, it will be used for sorting on multiple fields:
|
139
143
|
|
140
|
-
```
|
144
|
+
```erb
|
141
145
|
<%= sort_link(@q, :last_name, [:last_name, 'first_name asc'], 'Last Name') %>
|
142
146
|
```
|
143
147
|
|
@@ -148,7 +152,7 @@ Ransack to _always_ sort that particular field in the specified direction.
|
|
148
152
|
Multiple `default_order` fields may also be specified with a trailing options
|
149
153
|
Hash:
|
150
154
|
|
151
|
-
```
|
155
|
+
```erb
|
152
156
|
<%= sort_link(@q, :last_name, %i(last_name first_name),
|
153
157
|
default_order: { last_name: 'asc', first_name: 'desc' }) %>
|
154
158
|
```
|
@@ -162,7 +166,7 @@ of a SQL function, you may do so using scopes. In your model, define scopes
|
|
162
166
|
whose names line up with the name of the virtual field you wish to sort by,
|
163
167
|
as so:
|
164
168
|
|
165
|
-
```
|
169
|
+
```ruby
|
166
170
|
class Person < ActiveRecord::Base
|
167
171
|
scope :sort_by_reverse_name_asc, lambda { order("REVERSE(name) ASC") }
|
168
172
|
scope :sort_by_reverse_name_desc, lambda { order("REVERSE(name) DESC") }
|
@@ -171,7 +175,7 @@ class Person < ActiveRecord::Base
|
|
171
175
|
|
172
176
|
and you can then sort by this virtual field:
|
173
177
|
|
174
|
-
```
|
178
|
+
```erb
|
175
179
|
<%= sort_link(@q, :reverse_name) %>
|
176
180
|
```
|
177
181
|
|
@@ -186,7 +190,7 @@ You can also enable a `default_arrow` which is displayed on all sortable fields
|
|
186
190
|
which are not currently used in the sorting. This is disabled by default so
|
187
191
|
nothing will be displayed:
|
188
192
|
|
189
|
-
```
|
193
|
+
```ruby
|
190
194
|
Ransack.configure do |c|
|
191
195
|
c.custom_arrows = {
|
192
196
|
up_arrow: '<i class="custom-up-arrow-icon"></i>',
|
@@ -200,7 +204,7 @@ All sort links may be displayed without the order indicator
|
|
200
204
|
arrows by setting `hide_sort_order_indicators` to true in the initializer file.
|
201
205
|
Note that this hides the arrows even if they were customized:
|
202
206
|
|
203
|
-
```
|
207
|
+
```ruby
|
204
208
|
Ransack.configure do |c|
|
205
209
|
c.hide_sort_order_indicators = true
|
206
210
|
end
|
@@ -209,7 +213,7 @@ end
|
|
209
213
|
Without setting it globally, individual sort links may be displayed without
|
210
214
|
the order indicator arrow by passing `hide_indicator: true` in the sort link:
|
211
215
|
|
212
|
-
```
|
216
|
+
```erb
|
213
217
|
<%= sort_link(@q, :name, hide_indicator: true) %>
|
214
218
|
```
|
215
219
|
|
@@ -219,15 +223,15 @@ Ransack's `sort_url` helper is like a `sort_link` but returns only the url
|
|
219
223
|
|
220
224
|
`sort_url` has the same API as `sort_link`:
|
221
225
|
|
222
|
-
```
|
226
|
+
```erb
|
223
227
|
<%= sort_url(@q, :name, default_order: :desc) %>
|
224
228
|
```
|
225
229
|
|
226
|
-
```
|
230
|
+
```erb
|
227
231
|
<%= sort_url(@q, :last_name, [:last_name, 'first_name asc']) %>
|
228
232
|
```
|
229
233
|
|
230
|
-
```
|
234
|
+
```erb
|
231
235
|
<%= sort_url(@q, :last_name, %i(last_name first_name),
|
232
236
|
default_order: { last_name: 'asc', first_name: 'desc' }) %>
|
233
237
|
```
|
@@ -238,7 +242,7 @@ The `NULLS FIRST` and `NULLS LAST` options can be used to determine whether null
|
|
238
242
|
|
239
243
|
You may want to configure it like this:
|
240
244
|
|
241
|
-
```
|
245
|
+
```ruby
|
242
246
|
Ransack.configure do |c|
|
243
247
|
c.postgres_fields_sort_option = :nulls_first # or :nulls_last
|
244
248
|
end
|
@@ -246,7 +250,7 @@ end
|
|
246
250
|
|
247
251
|
To treat nulls as having the lowest or highest value respectively. To force nulls to always be first or last, use
|
248
252
|
|
249
|
-
```
|
253
|
+
```ruby
|
250
254
|
Ransack.configure do |c|
|
251
255
|
c.postgres_fields_sort_option = :nulls_always_first # or :nulls_always_last
|
252
256
|
end
|
@@ -258,7 +262,7 @@ See this feature: https://www.postgresql.org/docs/13/queries-order.html
|
|
258
262
|
|
259
263
|
In order to request PostgreSQL to do a case insensitive sort for all string columns of a model at once, Ransack can be extended by using this approach:
|
260
264
|
|
261
|
-
```
|
265
|
+
```ruby
|
262
266
|
module RansackObject
|
263
267
|
|
264
268
|
def self.included(base)
|
@@ -273,7 +277,7 @@ module RansackObject
|
|
273
277
|
end
|
274
278
|
```
|
275
279
|
|
276
|
-
```
|
280
|
+
```ruby
|
277
281
|
class UserWithManyAttributes < ActiveRecord::Base
|
278
282
|
include RansackObject
|
279
283
|
end
|
@@ -14,7 +14,7 @@ chances are you might want to search on tagged fields. Follow the instructions t
|
|
14
14
|
|
15
15
|
You can call the tagging field anything you like, it just needs to be plural. No migration is needed as this is stored in the internal ActsAsTaggable tables (`tags` and `taggings`).
|
16
16
|
|
17
|
-
```
|
17
|
+
```ruby
|
18
18
|
class Task < ApplicationRecord
|
19
19
|
acts_as_taggable_on :projects
|
20
20
|
end
|
@@ -26,7 +26,7 @@ Add a field to strong params in the controller. Use the singular name with `_lis
|
|
26
26
|
|
27
27
|
`app/controllers/tasks_controller.rb`
|
28
28
|
|
29
|
-
```
|
29
|
+
```ruby
|
30
30
|
def strong_params
|
31
31
|
params
|
32
32
|
.require(:tasks)
|
@@ -37,7 +37,7 @@ def strong_params
|
|
37
37
|
|
38
38
|
We need to `send` the tag fieldname to our model, also using the singular naming.
|
39
39
|
|
40
|
-
```
|
40
|
+
```erb
|
41
41
|
<div class='form-group'>
|
42
42
|
<%= f.label :project_list %>
|
43
43
|
<%= f.text_field :project_list, value: @task.send(:project_list).to_s %>
|
@@ -50,7 +50,7 @@ Now we can collect our data via the form, with tags separated by commas.
|
|
50
50
|
|
51
51
|
Imagine you have the following two instances of `Task`:
|
52
52
|
|
53
|
-
```
|
53
|
+
```ruby
|
54
54
|
{ id: 1, name: 'Clean up my room', projects: [ 'Home', 'Personal' ] }
|
55
55
|
{ id: 2, name: 'Complete math exercises', projects: [ 'Homework', 'Study' ] }
|
56
56
|
```
|
@@ -67,24 +67,24 @@ When you're writing a `Ransack` search form, you can choose any of the following
|
|
67
67
|
|
68
68
|
### Option A - Match keys exactly
|
69
69
|
|
70
|
-
Option `
|
70
|
+
Option `A` will match keys exactly. This is the solution to choose if you want to distinguish 'Home' from 'Homework': searching for 'Home' will return just the `Task` with id 1. It also allows searching for more than one tag at once (comma separated):
|
71
71
|
- `Home, Personal` will return task 1
|
72
72
|
- `Home, Homework` will return task 1 and 2
|
73
73
|
|
74
74
|
### Option B - match key combinations
|
75
75
|
|
76
|
-
Option `
|
76
|
+
Option `B` will match all keys exactly. This is the solution if you wanna search for specific combinations of tags:
|
77
77
|
- `Home` will return nothing, as there is no Task with just the `Home` tag
|
78
78
|
- `Home, Personal` will return task 1
|
79
79
|
|
80
80
|
### Option C - match substrings
|
81
81
|
|
82
|
-
Option `
|
82
|
+
Option `C` is used to match substrings. This is useful when you don't care for the exact tag, but only for part of it:
|
83
83
|
- `Home` will return task 1 and 2 (`/Home/` matches both `"Home"` and `"Homework"`)
|
84
84
|
|
85
85
|
### Option D - select from a list of tags
|
86
86
|
|
87
|
-
In Option D we allow the user to select a list of valid tags and then search
|
87
|
+
In Option `D` we allow the user to select a list of valid tags and then search against them. We use the plural name here.
|
88
88
|
|
89
89
|
```erb
|
90
90
|
<div class='form-group'>
|
@@ -97,7 +97,7 @@ In Option D we allow the user to select a list of valid tags and then search aga
|
|
97
97
|
|
98
98
|
ActsAsTaggableOn allows scoping of tags based on another field on the model. Suppose we have a `language` field on the model, as an effective second level key. We would adjust our model to look like this:
|
99
99
|
|
100
|
-
```
|
100
|
+
```ruby
|
101
101
|
class Task < ApplicationRecord
|
102
102
|
acts_as_taggable_on :projects
|
103
103
|
acts_as_taggable_tenant :language
|
@@ -106,7 +106,7 @@ end
|
|
106
106
|
|
107
107
|
The Ransack search is then filtered using the `for_tenant` method
|
108
108
|
|
109
|
-
```
|
109
|
+
```erb
|
110
110
|
<div class='form-group'>
|
111
111
|
<%= f.label :projects_name, 'Project' %>
|
112
112
|
<%= f.select :projects_name_in, ActsAsTaggableOn::Tag.for_tenant('fr').distinct.order(:name).pluck(:name) %>
|
@@ -7,7 +7,7 @@ Exporting to CSV
|
|
7
7
|
|
8
8
|
Example downloading a csv file preserving ransack search, based on [this gist](https://gist.github.com/pama/adff25ed1f4b796ce088ea362a08e1c5)
|
9
9
|
|
10
|
-
```
|
10
|
+
```ruby title='index.html.erb'
|
11
11
|
<h1>Users</h1>
|
12
12
|
|
13
13
|
<%= search_form_for @q, url: dashboard_index_path do |f| %>
|
@@ -30,7 +30,7 @@ Example downloading a csv file preserving ransack search, based on [this gist](h
|
|
30
30
|
<% end %>
|
31
31
|
```
|
32
32
|
|
33
|
-
```
|
33
|
+
```ruby title='user.rb'
|
34
34
|
require 'csv'
|
35
35
|
|
36
36
|
class User < ApplicationRecord
|
@@ -3,7 +3,7 @@ sidebar_position: 4
|
|
3
3
|
title: Form customisation
|
4
4
|
---
|
5
5
|
|
6
|
-
Predicate and attribute labels in forms may be specified with I18n in a translation file (see the locale files in [Ransack::Locale](https://github.com/activerecord-hackery/ransack/
|
6
|
+
Predicate and attribute labels in forms may be specified with I18n in a translation file (see the locale files in [Ransack::Locale](https://github.com/activerecord-hackery/ransack/tree/main/lib/ransack/locale) for more examples):
|
7
7
|
|
8
8
|
```yml
|
9
9
|
# locales/en.yml
|
@@ -6,12 +6,12 @@ title: i18n
|
|
6
6
|
# i18n and Ransack
|
7
7
|
|
8
8
|
Ransack translation files are available in
|
9
|
-
[Ransack::Locale](https://github.com/activerecord-hackery/ransack/lib/ransack/locale). You may also be interested in one of the
|
9
|
+
[Ransack::Locale](https://github.com/activerecord-hackery/ransack/tree/main/lib/ransack/locale). You may also be interested in one of the
|
10
10
|
many translations for Ransack available at
|
11
11
|
http://www.localeapp.com/projects/2999.
|
12
12
|
|
13
13
|
Predicate and attribute translations in forms may be specified as follows (see
|
14
|
-
the translation files in [Ransack::Locale](https://github.com/activerecord-hackery/ransack/lib/ransack/locale) for more examples):
|
14
|
+
the translation files in [Ransack::Locale](https://github.com/activerecord-hackery/ransack/tree/main/lib/ransack/locale) for more examples):
|
15
15
|
|
16
16
|
locales/en.yml:
|
17
17
|
```yml
|
@@ -27,7 +27,7 @@ en:
|
|
27
27
|
gt: greater than
|
28
28
|
lt: less than
|
29
29
|
models:
|
30
|
-
person:
|
30
|
+
person: Passenger
|
31
31
|
attributes:
|
32
32
|
person:
|
33
33
|
name: Full Name
|
@@ -354,7 +354,7 @@ argument are not easily usable yet, because the array currently needs to be
|
|
354
354
|
wrapped in an array to function (see
|
355
355
|
[this issue](https://github.com/activerecord-hackery/ransack/issues/404)),
|
356
356
|
which is not compatible with Ransack form helpers. For this use case, it may be
|
357
|
-
better for now to use [ransackers](https://
|
357
|
+
better for now to use [ransackers](https://activerecord-hackery.github.io/ransack/going-further/ransackers) instead,
|
358
358
|
where feasible. Pull requests with solutions and tests are welcome!
|
359
359
|
|
360
360
|
### Grouping queries by OR instead of AND
|
@@ -72,7 +72,7 @@ class ApplicationController < ActionController::Base
|
|
72
72
|
end
|
73
73
|
|
74
74
|
protected
|
75
|
-
# GENERATE A GENERIC SESSION KEY BASED ON
|
75
|
+
# GENERATE A GENERIC SESSION KEY BASED ON THE CONTROLLER NAME
|
76
76
|
def search_key
|
77
77
|
"#{controller_name}_search".to_sym
|
78
78
|
end
|
@@ -13,7 +13,7 @@ See [this issue](https://github.com/activerecord-hackery/ransack/issues/321) for
|
|
13
13
|
|
14
14
|
### Using a fixed key
|
15
15
|
|
16
|
-
See here for searching on a fixed key in a JSONB column: https://
|
16
|
+
See here for searching on a fixed key in a JSONB column: https://activerecord-hackery.github.io/ransack/going-further/ransackers/#postgres-columns
|
17
17
|
|
18
18
|
### Using the JSONB contains operator
|
19
19
|
|
data/docs/docs/intro.md
CHANGED
@@ -17,7 +17,7 @@ Ransack is supported for Rails 7.0, 6.x on Ruby 2.6.6 and later.
|
|
17
17
|
|
18
18
|
To install `ransack` and add it to your Gemfile, run
|
19
19
|
|
20
|
-
```
|
20
|
+
```ruby title='Gemfile'
|
21
21
|
gem 'ransack'
|
22
22
|
```
|
23
23
|
|
@@ -25,7 +25,7 @@ gem 'ransack'
|
|
25
25
|
|
26
26
|
If you would like to use the latest updates not yet published to RubyGems, use the `main` branch:
|
27
27
|
|
28
|
-
```
|
28
|
+
```ruby title='Gemfile'
|
29
29
|
gem 'ransack', :github => 'activerecord-hackery/ransack', :branch => 'main'
|
30
30
|
```
|
31
31
|
|
data/docs/docusaurus.config.js
CHANGED
@@ -15,7 +15,7 @@ const config = {
|
|
15
15
|
favicon: 'img/favicon.ico',
|
16
16
|
organizationName: 'activerecord-hackery',
|
17
17
|
projectName: 'ransack',
|
18
|
-
trailingSlash:
|
18
|
+
trailingSlash: true,
|
19
19
|
|
20
20
|
presets: [
|
21
21
|
[
|
@@ -100,8 +100,21 @@ const config = {
|
|
100
100
|
prism: {
|
101
101
|
theme: lightCodeTheme,
|
102
102
|
darkTheme: darkCodeTheme,
|
103
|
+
additionalLanguages: ['ruby', 'erb'],
|
103
104
|
},
|
104
105
|
}),
|
106
|
+
|
107
|
+
themes: [
|
108
|
+
[
|
109
|
+
require.resolve("@easyops-cn/docusaurus-search-local"),
|
110
|
+
{
|
111
|
+
// `hashed` is recommended as long-term-cache of index file is possible.
|
112
|
+
hashed: true,
|
113
|
+
// needs to be the same as routeBasePath in @docusaurus/preset-classic config
|
114
|
+
docsRouteBasePath: '/'
|
115
|
+
},
|
116
|
+
]
|
117
|
+
]
|
105
118
|
};
|
106
119
|
|
107
120
|
module.exports = config;
|
data/docs/package.json
CHANGED
@@ -14,14 +14,19 @@
|
|
14
14
|
"write-heading-ids": "docusaurus write-heading-ids"
|
15
15
|
},
|
16
16
|
"dependencies": {
|
17
|
-
"@docusaurus/core": "2.
|
18
|
-
"@docusaurus/preset-classic": "2.
|
17
|
+
"@docusaurus/core": "^2.2.0",
|
18
|
+
"@docusaurus/preset-classic": "^2.2.0",
|
19
|
+
"@easyops-cn/docusaurus-search-local": "^0.33.5",
|
19
20
|
"@mdx-js/react": "^1.6.22",
|
20
21
|
"clsx": "^1.1.1",
|
21
22
|
"prism-react-renderer": "^1.3.1",
|
22
23
|
"react": "^17.0.2",
|
23
24
|
"react-dom": "^17.0.2"
|
24
25
|
},
|
26
|
+
"resolutions": {
|
27
|
+
"trim": "^0.0.3",
|
28
|
+
"got": "^11.8.5"
|
29
|
+
},
|
25
30
|
"browserslist": {
|
26
31
|
"production": [
|
27
32
|
">0.5%",
|