Commit b8a8991
authored
Refactor/pagefind search (#2879)
* Add pagefind search result utility files
* Remvove pagefind-ui.css & load pagefind.js dynamically
No longer a need for pagefind-ui.css as we will be referencing our own
custom CSS instead. Likewise, we no longern eed PagefindUI's js.
Dynamically imports pagefind by lazy loading it each time the search
opens.
* Fix import path in page.njk
* Replace PagefindUI with pagefind.js API in Search.vue
Removed deep() overrides with custom css
Update keyboard navigation using selectedIndex state
Remove MutationObserver and innerHTML hacky solution
Implemented custom result rendering
* Update styling for Search.vue
* Update pagefind search utils to process subresult status
Included an additional field subResult fields in FormattedSearchResult
to detect whether the result if a subResult and if it is the last
subResult.
Updated Search.vue results to indicate if a result if a main result or a
search result with svgs. Svgs were taken from algolia's design on the
cs2103 website.
* Fix bug first index sub result and Clean search.css
The occured as the first sub result would be essentially the same as the
main result. This is because our page names and their first heading are
usually the same contributing to this error. For example,
makingTheSiteSearchable.html is the same as
makingTheSiteSearchable.html#making-the-site-searchable.
Hence, by checking of the sub result's title is the same as the main
result's title, we can identify which sub result to not include when
displaying the data.
Also search.css by removing accidentally duplicated code and
restructuring the order of the class selectors in a more logical manner.
Also included more comments explaining and breaking down the classes
into different sections for easier understandability. Word lol
* Update styling for mark & font sizes
* Fix mark component not appearing in excerpt bug
Some of the marked components were not appearing as they were being cut
off within the elipsis due to the length of the excerpt displayed.
Hence, instead, it now processes the excerpt length to display a maximum
of 15 characters before it to ensure that the marked components are
always included.
* Add nowrap for result titles styling
This was mainly discovered because I found a bug where it seems that
pagefind is indexing the headers generated within generated
<question></question>. As a result, since these titles are extremely
long, it ended up completely hiding the excerpt part of the
search-result-item.
Hence, this warrants a change by first ensuring that nowrap on the title
to ensure that it only displays the first part of the header.
And also, I need to raise a issue for the bug as I don't think we should
be letting pagefind index these generated headers.
* Add merging of consecutive marked terms
This will ensure that they are displayed as one segment instead of 2
distinct segements when the search terms are next to each other within
the excerpt.
* Fix bug storing only duplicated sub-results not unique
Previous it was adding duplicated sub-results instead of unqiue ones.
E.g.when searching "refactoring" in 2103 site, it was would store 10
(the count limt) copies of the "What" subresult instead of the other
sub-sections (How, When, etc).
This happened because it was iterating through each weighted location
(i.e. the search term position). And for each, it would select the
sub-result with the most context, after which it would push the it into
the sub array without checking for duplicates. Hence, using the 2103
site example from before, there were >=10 instances of "Refactoring" in
"What" section, it was interating through these instances until it
reached the 10 count limit. After which, the filters to remove the
duplicated entries would result in only mention of the "What" section
being displayed, which meant that it would only display "Refactoring"
with 1 sub result -> "What" section.
Hence, to fix this, I added a duplicate check before pushing subs array.
Now we will only store the FIRST instance of each sub-result. Hence
"What" is stored once, and it will allow the correct storing of the
other sections as well. This ensures that we can display the actual
maximum of 10 sub-results.
* Add more DocSearch styling
* Use score instead of weight when sorting
* Create testcases for searchUtils
* Rehaul tests for Search.vue
* Update functional tests
* Update functional test (again)
* Export as types & used numeric check
* Resolve Search.vue code quality issues
* Create pagefind-lazloader.js & update functional tests
* Fix assets manager bug
* Update functional tests
* Fix weight order issue1 parent cb0edbc commit b8a8991
136 files changed
Lines changed: 1951 additions & 678 deletions
File tree
- packages
- cli/test/functional
- test_site_algolia_plugin/expected
- markbind/js
- test_site_convert
- test_basic_convert/expected
- contents
- markbind/js
- test_site_custom_plugins/expected
- markbind/js
- test_site_special_tags/expected
- markbind/js
- test_site_table_plugin/expected
- markbind/js
- test_site_templates
- test_default/expected
- contents
- markbind/js
- test_minimal/expected
- markbind/js
- test_portfolio/expected
- markbind/js
- test_project/expected
- developerGuide
- markbind/js
- team
- userGuide
- test_site/expected
- bugs
- markbind/js
- sub_site
- nested_sub_site
- core-web/asset/js
- core
- src
- Pagefind
- Page
- Site
- test/unit/Pagefind
- vue-components/src
- __tests__
- pagefindSearchBar
- assets
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
360 | 359 | | |
361 | 360 | | |
362 | 361 | | |
363 | | - | |
| 362 | + | |
364 | 363 | | |
365 | 364 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
1026 | 1025 | | |
1027 | 1026 | | |
1028 | 1027 | | |
1029 | | - | |
| 1028 | + | |
1030 | 1029 | | |
1031 | 1030 | | |
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
367 | 366 | | |
368 | 367 | | |
369 | 368 | | |
370 | | - | |
| 369 | + | |
371 | 370 | | |
372 | 371 | | |
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
358 | 357 | | |
359 | 358 | | |
360 | 359 | | |
361 | | - | |
| 360 | + | |
362 | 361 | | |
363 | 362 | | |
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
364 | 363 | | |
365 | 364 | | |
366 | 365 | | |
367 | | - | |
| 366 | + | |
368 | 367 | | |
369 | 368 | | |
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
364 | 363 | | |
365 | 364 | | |
366 | 365 | | |
367 | | - | |
| 366 | + | |
368 | 367 | | |
369 | 368 | | |
0 commit comments