Fixed multi-language search

This commit is contained in:
squidfunk 2020-02-19 15:45:52 +01:00
parent 8171fc0ecd
commit 577ad4ccc4
14 changed files with 36 additions and 35 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,10 @@
{
"assets/javascripts/bundle.js": "assets/javascripts/bundle.3428f4d3.min.js",
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.3428f4d3.min.js.map",
"assets/javascripts/bundle.js": "assets/javascripts/bundle.274c4c16.min.js",
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.274c4c16.min.js.map",
"assets/javascripts/worker/packer.js": "assets/javascripts/worker/packer.c14659e8.min.js",
"assets/javascripts/worker/packer.js.map": "assets/javascripts/worker/packer.c14659e8.min.js.map",
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.0a5433f7.min.js",
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.0a5433f7.min.js.map",
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.926ffd9e.min.js",
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.926ffd9e.min.js.map",
"assets/stylesheets/app-palette.scss": "assets/stylesheets/app-palette.3f90c815.min.css",
"assets/stylesheets/app.scss": "assets/stylesheets/app.0f079138.min.css"
}

View File

@ -190,7 +190,7 @@
{% endblock %}
</div>
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.3428f4d3.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.274c4c16.min.js' | url }}"></script>
<script id="__lang" type="application/json">
{%- set translations = {} -%}
{%- for key in [
@ -209,7 +209,7 @@
{%- endfor -%}
{{ translations | tojson }}
</script>
<script>app=initialize({base:"{{ base_url }}",worker:{search:"{{ 'assets/javascripts/worker/search.0a5433f7.min.js' | url }}",packer:"{{ 'assets/javascripts/worker/packer.c14659e8.min.js' | url }}"}})</script>
<script>app=initialize({base:"{{ base_url }}",worker:{search:"{{ 'assets/javascripts/worker/search.926ffd9e.min.js' | url }}",packer:"{{ 'assets/javascripts/worker/packer.c14659e8.min.js' | url }}"}})</script>
{% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script>
{% endfor %}

6
package-lock.json generated
View File

@ -2459,6 +2459,12 @@
"homedir-polyfill": "^1.0.1"
}
},
"expose-loader": {
"version": "0.7.5",
"resolved": "https://registry.npmjs.org/expose-loader/-/expose-loader-0.7.5.tgz",
"integrity": "sha512-iPowgKUZkTPX5PznYsmifVj9Bob0w2wTHVkt/eYNPSzyebkUgIedmskf/kcfEIWpiWjg3JRjnW+a17XypySMuw==",
"dev": true
},
"extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",

View File

@ -59,6 +59,7 @@
"css-loader": "^3.4.2",
"css-mqpacker": "^7.0.0",
"event-hooks-webpack-plugin": "^2.1.5",
"expose-loader": "^0.7.5",
"extract-loader": "^4.0.3",
"file-loader": "^5.0.2",
"github-types": "^1.0.0",

View File

@ -54,9 +54,7 @@ import {
watchViewport,
watchKeyboard,
watchToggleMap,
useToggle,
getActiveElement,
mayReceiveKeyboardEvents
useToggle
} from "./observables"
import { setupSearchWorker } from "./workers"

View File

@ -70,10 +70,14 @@ export function setupClipboard(
})
/* Initialize and setup clipboard */
return fromEventPattern<ClipboardJS.Event>(next => {
const clipboard = new ClipboardJS(".md-clipboard")
clipboard.on("success", next)
const clipboard$ = fromEventPattern<ClipboardJS.Event>(next => {
new ClipboardJS(".md-clipboard").on("success", next)
})
// TODO: integrate rendering of dialog
/* */
return clipboard$
.pipe(
shareReplay(1)
)

View File

@ -20,6 +20,8 @@
* IN THE SOFTWARE.
*/
import "expose-loader?lunr!lunr"
import { SearchIndex, SearchIndexConfig } from "integrations/search"
import { SearchMessage, SearchMessageType } from "../message"
@ -56,7 +58,7 @@ function setupLunrLanguages(config: SearchIndexConfig): void {
}
/* Add multi-language support */
if (scripts.length > 1)
if (config.lang.length > 1)
scripts.push(`${base}/min/lunr.multi.min.js`)
/* Load scripts synchronously */

View File

@ -28,7 +28,7 @@ import * as path from "path"
import { toPairs } from "ramda"
import { minify as minjs } from "terser"
import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin"
import { Configuration, ProvidePlugin } from "webpack"
import { Configuration } from "webpack"
import * as AssetsManifestPlugin from "webpack-assets-manifest"
/* ----------------------------------------------------------------------------
@ -286,17 +286,7 @@ export default (_env: never, args: Configuration): Configuration[] => {
filename: `[name]${hash}.js`,
hashDigestLength: 8,
libraryTarget: "var"
},
/* Plugins */
plugins: [
...base.plugins,
/* Inject globals */
new ProvidePlugin({
lunr: "lunr"
})
]
}
},
/* Packer worker */