lunr multi language search support

This commit is contained in:
zzossig 2019-11-14 17:55:50 +09:00
parent a52a473d4b
commit dc08a64178
2 changed files with 105 additions and 1 deletions

View File

@ -19,11 +19,22 @@
sri = "sha256-TabprKdeNXbSesCWLMrcbWSDzUhpAdcNPe5Q53rn9Yg="
url = "https://cdn.jsdelivr.net/npm/raphael@2.3.0/raphael.min.js"
# css
[css.katex]
sri = "sha256-V8SV2MO1FUb63Bwht5Wx9x6PVHNa02gv8BgH/uH3ung="
url = "https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css"
# lunr languages
[js.stemmer]
code = "stemmer"
@ -35,7 +46,97 @@
sri = "sha256-l2H0da5582Qg/3FN+ZUO+yZO/8+SMO/VW1EaDeiZ6Xk="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.multi.min.js"
[lunr.ar]
code = "ar"
sri = "sha256-OQf/d8ARJV1yW5ij9fwh2nKphCnG3T/b1HCwqX/6oyQ="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.ar.min.js"
[lunr.da]
code = "da"
sri = "sha256-KhJzQEjq504KBeXBCP3yTCtx382NpxIzbKnj0nq5KVY="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.da.min.js"
[lunr.de]
code = "de"
sri = "sha256-vKp8XBm8cwwFu5HiKuDjhuGsSgWAxCt9lPm4dXqtras="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.de.min.js"
[lunr.du]
code = "du"
sri = "sha256-RS2gT+RJucZcYThP7FgtxjgkvU5Vn64sOSaneQto6XY="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.du.min.js"
[lunr.es]
code = "es"
sri = "sha256-3sTskL1vR4yj5lY2qOP+31ErI9AaUaAdfngi9n67qvg="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.es.min.js"
[lunr.fi]
code = "fi"
sri = "sha256-aBVB/PWxmHrYsAdm6cBjiez5nD166Bf6iR+SP2kbhmg="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.fi.min.js"
[lunr.fr]
code = "fr"
sri = "sha256-TdVqolUedwrSbvS4UJLNMUR2ceDoSzlRQnhUf1QXc3c="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.fr.min.js"
[lunr.hu]
code = "hu"
sri = "sha256-h2yWm79KK4Rzj04KFJIu4zHLfCGTpiH2Xbf4Nv3TOjg="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.hu.min.js"
[lunr.it]
code = "it"
sri = "sha256-AKUHPfLpIuX97RxaTUARrsAkcqudkYKnxlCNYLYlxFM="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.it.min.js"
[lunr.ja]
code = "ja"
sri = "sha256-xP3tMI9jNoGm7VO2wQ2MpZFv39UPa4LskU1yW+DLi9Y="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.ja.min.js"
[lunr.jp]
code = "jp"
sri = "sha256-BBFO3DbcEU7c5a+7PH95X0XHfYZzwe3NylZ13atdUZk="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.jp.min.js"
[lunr.nl]
code = "nl"
sri = "sha256-OZ7ybWHtLVgG9Y6nI9+soJ9KfJtR4xW90XSCyOMBOj4="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.nl.min.js"
[lunr.no]
code = "no"
sri = "sha256-V/nbkpD57TYIB1X1PuNCoE9VpZVOSt2RXRwwGjdGRXM="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.no.min.js"
[lunr.pt]
code = "pt"
sri = "sha256-OiXSq6ojBjzxP8VsGa5MxQUMtiFRFenQj0pvS3h4AGc="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.pt.min.js"
[lunr.ro]
code = "ro"
sri = "sha256-z6JqjqQpPYHoVHuiMh1wOg/piB8HIfyl8zo/gL8Vbuk="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.ro.min.js"
[lunr.ru]
code = "ru"
sri = "sha256-UO88D6tKPy0mDolzxjNjqg3PArVZ6p0R1fArYZdYXBc="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.ru.min.js"
[lunr.sv]
code = "sv"
sri = "sha256-lCsWW8yCGOMkb8RzWvmxwvZlFDZtAAC+BRvxu4ltQT4="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.sv.min.js"
[lunr.tr]
code = "tr"
sri = "sha256-6L9XsQM7i9kuoEqUxTMBWqGn8KjWgwGUuXTpTh5Kyjw="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.tr.min.js"
[lunr.vi]
code = "vi"
sri = "sha256-LjnD/XMF9uZvwEJHlqdpbLjjbcD1w6g+obxE3+P+y1Y="
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.vi.min.js"

View File

@ -22,9 +22,12 @@
{{ $multi := .Site.Data.lib.js.multi_language }}
{{ printf "<script defer src=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\" title=\"%s\"></script>" $multi.url $multi.sri $multi.code | safeHTML }}
{{ $searchLanguages := .Site.Params.searchLanguages }}
{{ range .Site.Data.lib.lunr }}
{{ if in $searchLanguages .code }}
{{ printf "<script defer src=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\" title=\"%s\"></script>" .url .sri .code | safeHTML }}
{{ end }}
{{ end }}
<script>
{{ if .Site.IsMultiLingual }}