mirror of
https://github.com/dillonzq/LoveIt.git
synced 2025-03-13 11:18:15 +01:00
feat: upgrade algoliasearch client from v4.13.1 to v5.20.2 (#909)
This commit is contained in:
parent
290f9c66b6
commit
4d9ea2987f
11 changed files with 1067 additions and 890 deletions
2
.babelrc
2
.babelrc
|
@ -3,7 +3,7 @@
|
|||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"targets": "> 0.25%, not dead"
|
||||
"targets": "> 0.01%"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
|
|
@ -11,8 +11,8 @@ libFiles:
|
|||
autocompleteJS: autocomplete.js/0.38.1/autocomplete.min.js
|
||||
# lunr.js@2.3.9 https://lunrjs.com/
|
||||
lunrJS: lunr.js/2.3.9/lunr.min.js
|
||||
# algoliasearch@4.13.1 https://github.com/algolia/algoliasearch-client-javascript
|
||||
algoliasearchJS: algoliasearch/4.13.1/algoliasearch-lite.umd.min.js
|
||||
# algoliasearch@5.19.0 https://github.com/algolia/algoliasearch-client-javascript
|
||||
algoliasearchJS: algoliasearch/5.19.0/lite/builds/browser.umd.min.js
|
||||
# lazysizes@5.3.2 https://github.com/aFarkas/lazysizes
|
||||
lazysizesJS: lazysizes/5.3.2/lazysizes.min.js
|
||||
# object-fit-images@3.2.4 https://github.com/fregante/object-fit-images
|
||||
|
|
|
@ -11,8 +11,8 @@ libFiles:
|
|||
autocompleteJS: autocomplete.js@0.38.1/dist/autocomplete.min.js
|
||||
# lunr.js@2.3.9 https://lunrjs.com/
|
||||
lunrJS: lunr@2.3.9/lunr.min.js
|
||||
# algoliasearch@4.13.1 https://github.com/algolia/algoliasearch-client-javascript
|
||||
algoliasearchJS: algoliasearch@4.13.1/dist/algoliasearch-lite.umd.min.js
|
||||
# algoliasearch@5.20.2 https://github.com/algolia/algoliasearch-client-javascript
|
||||
algoliasearchJS: algoliasearch@5.20.2/dist/lite/builds/browser.umd.min.js
|
||||
# lazysizes@5.3.2 https://github.com/aFarkas/lazysizes
|
||||
lazysizesJS: lazysizes@5.3.2/lazysizes.min.js
|
||||
# object-fit-images@3.2.4 https://github.com/fregante/object-fit-images
|
||||
|
|
1878
assets/js/theme.js
1878
assets/js/theme.js
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
| Dependency Library | Directory | Version |
|
||||
|:------------------------------------------------------------------------------------|:------------------|--------:|
|
||||
| [Algolia Search Clinet](https://github.com/algolia/algoliasearch-client-javascript) | algoliasearch | 4.13.1 |
|
||||
| [Algolia Search Clinet](https://github.com/algolia/algoliasearch-client-javascript) | algoliasearch | 5.20.2 |
|
||||
| [Animate.css](https://github.com/daneden/animate.css) | animate | 4.1.1 |
|
||||
| [APlayer](https://github.com/MoePlayer/APlayer) | aplayer | 1.10.1 |
|
||||
| [Autocomplete](https://github.com/algolia/autocomplete) | autocomplete | 0.38.1 |
|
||||
|
|
File diff suppressed because one or more lines are too long
12
assets/lib/algoliasearch/lite/browser.umd.js
Normal file
12
assets/lib/algoliasearch/lite/browser.umd.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -173,11 +173,13 @@ n.CHS_NAMES=T,n.ChsNameOptimizer=Z,n.ChsNameTokenizer=k,n.DatetimeOptimizer=$,n.
|
|||
|
||||
var _segmentit = require("segmentit");
|
||||
|
||||
const segmentit = (0, _segmentit.useDefault)(new _segmentit.Segment());
|
||||
var segmentit = (0, _segmentit.useDefault)(new _segmentit.Segment());
|
||||
lunr.segmentit = segmentit;
|
||||
|
||||
lunr.queryHandler = query => {
|
||||
if (/^[\u4e00-\u9fa5]+$/.test(query)) query = lunr.segmentit.doSegment(query).map(seg => '+' + seg.w).join(' ');
|
||||
lunr.queryHandler = function (query) {
|
||||
if (/^[\u4e00-\u9fa5]+$/.test(query)) query = lunr.segmentit.doSegment(query).map(function (seg) {
|
||||
return '+' + seg.w;
|
||||
}).join(' ');
|
||||
return query;
|
||||
};
|
||||
|
||||
|
|
|
@ -859,9 +859,9 @@ ignoreErrors = ["error-remote-getjson", "error-missing-instagram-accesstoken"]
|
|||
highlightTag = "em"
|
||||
absoluteURL = false
|
||||
[languages.en.params.search.algolia]
|
||||
index = "index.en"
|
||||
appID = "PASDMWALPK"
|
||||
searchKey = "b42948e51daaa93df92381c8e2ac0f93"
|
||||
index = "index"
|
||||
appID = "4D1IDY8JU6"
|
||||
searchKey = "05332ac5ed76655a511f0da583a9afac"
|
||||
[languages.en.params.home]
|
||||
rss = 10
|
||||
[languages.en.params.home.profile]
|
||||
|
@ -952,9 +952,9 @@ ignoreErrors = ["error-remote-getjson", "error-missing-instagram-accesstoken"]
|
|||
highlightTag = "em"
|
||||
absoluteURL = false
|
||||
[languages.zh-cn.params.search.algolia]
|
||||
index = "index.zh-cn"
|
||||
appID = "PASDMWALPK"
|
||||
searchKey = "b42948e51daaa93df92381c8e2ac0f93"
|
||||
index = "index"
|
||||
appID = "GZT24PWKNT"
|
||||
searchKey = "634ab679e825b815de2663de38908f9d"
|
||||
[languages.zh-cn.params.home]
|
||||
rss = 10
|
||||
[languages.zh-cn.params.home.profile]
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
{{- dict "Source" (T "lunrLanguageLib") "Minify" true "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- end -}}
|
||||
{{- else if eq $search.type "algolia" -}}
|
||||
{{- $source := $cdn.algoliasearchJS | default "lib/algoliasearch/algoliasearch-lite.umd.min.js" -}}
|
||||
{{- $source := $cdn.algoliasearchJS | default "lib/algoliasearch/lite/browser.umd.js" -}}
|
||||
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- $config = dict "type" "algolia" "algoliaIndex" $search.algolia.index "algoliaAppID" $search.algolia.appID "algoliaSearchKey" $search.algolia.searchKey | dict "search" | merge $config -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -242,17 +242,24 @@ class Theme {
|
|||
});
|
||||
} else finish(search());
|
||||
} else if (searchConfig.type === 'algolia') {
|
||||
this._algoliaIndex = this._algoliaIndex || algoliasearch(searchConfig.algoliaAppID, searchConfig.algoliaSearchKey).initIndex(searchConfig.algoliaIndex);
|
||||
const { liteClient: algoliasearch } = window['algoliasearch/lite'];
|
||||
this._algoliaIndex = this._algoliaIndex || algoliasearch(searchConfig.algoliaAppID, searchConfig.algoliaSearchKey);
|
||||
this._algoliaIndex
|
||||
.search(query, {
|
||||
offset: 0,
|
||||
length: maxResultLength * 8,
|
||||
attributesToHighlight: ['title'],
|
||||
attributesToSnippet: [`content:${snippetLength}`],
|
||||
highlightPreTag: `<${highlightTag}>`,
|
||||
highlightPostTag: `</${highlightTag}>`,
|
||||
.search({
|
||||
requests: [
|
||||
{
|
||||
indexName: searchConfig.algoliaIndex,
|
||||
query: query,
|
||||
offset: 0,
|
||||
length: maxResultLength * 8,
|
||||
attributesToHighlight: ['title'],
|
||||
attributesToSnippet: [`content:${snippetLength}`],
|
||||
highlightPreTag: `<${highlightTag}>`,
|
||||
highlightPostTag: `</${highlightTag}>`,
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(({ hits }) => {
|
||||
.then(({ results: [{ hits }] }) => {
|
||||
const results = {};
|
||||
hits.forEach(({ uri, date, _highlightResult: { title }, _snippetResult: { content } }) => {
|
||||
if (results[uri] && results[uri].context.length > content.value) return;
|
||||
|
|
Loading…
Add table
Reference in a new issue