search engine changed to fuse.js, chinese, korean search support
This commit is contained in:
parent
aa71808f20
commit
586dffdef5
|
@ -225,7 +225,7 @@ enableThemeChange = true # site color theme
|
||||||
# body
|
# body
|
||||||
enableBreadcrumb = true # breadcrumb for list, single page
|
enableBreadcrumb = true # breadcrumb for list, single page
|
||||||
enablePhotoSwipe = true # image viewer for gallery, single page
|
enablePhotoSwipe = true # image viewer for gallery, single page
|
||||||
enableSearch = true # site search with lunr
|
enableSearch = true # site search with fuse
|
||||||
enableGoToTop = true # scroll to top
|
enableGoToTop = true # scroll to top
|
||||||
enableWhoami = true # at the end of single page
|
enableWhoami = true # at the end of single page
|
||||||
summaryShape = "classic" # card, classic, compact
|
summaryShape = "classic" # card, classic, compact
|
||||||
|
@ -251,7 +251,6 @@ enableSidebarCategories = true
|
||||||
enableToc = true # single page table of contents
|
enableToc = true # single page table of contents
|
||||||
enableTocSwitch = true # single page table of contents visibility switch
|
enableTocSwitch = true # single page table of contents visibility switch
|
||||||
itemsPerCategory = 5 # maximum number of posts shown in the sidebar.
|
itemsPerCategory = 5 # maximum number of posts shown in the sidebar.
|
||||||
searchLanguages = ['en'] # lunr multilanguage search. https://github.com/MihaiValentin/lunr-languages
|
|
||||||
|
|
||||||
# footer
|
# footer
|
||||||
showPoweredBy = true # show footer text: Powered by Hugo and Zzo theme
|
showPoweredBy = true # show footer text: Powered by Hugo and Zzo theme
|
||||||
|
|
|
@ -34,7 +34,7 @@ Thank you for click me!. Zzo theme is a blog theme powered by Hugo with free(alw
|
||||||
* Multilingual (i18n)
|
* Multilingual (i18n)
|
||||||
* Responsive design
|
* Responsive design
|
||||||
* RSS and JSON feeds with full content
|
* RSS and JSON feeds with full content
|
||||||
* Search with Lunr
|
* Search with Fuse
|
||||||
* Gallery with Masonry, Photoswipe
|
* Gallery with Masonry, Photoswipe
|
||||||
* Fast code highlighting
|
* Fast code highlighting
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ enableThemeChange = true # site color theme
|
||||||
# body
|
# body
|
||||||
enableBreadcrumb = true # breadcrumb for list, single page
|
enableBreadcrumb = true # breadcrumb for list, single page
|
||||||
enablePhotoSwipe = true # image viewer for gallery, single page
|
enablePhotoSwipe = true # image viewer for gallery, single page
|
||||||
enableSearch = true # site search with lunr
|
enableSearch = true # site search with Fuse
|
||||||
enableGoToTop = true # scroll to top
|
enableGoToTop = true # scroll to top
|
||||||
enableWhoami = true # at the end of single page
|
enableWhoami = true # at the end of single page
|
||||||
summaryShape = "classic" # card, classic, compact
|
summaryShape = "classic" # card, classic, compact
|
||||||
|
@ -246,7 +246,6 @@ enableSidebarCategories = true
|
||||||
enableToc = true # single page table of contents
|
enableToc = true # single page table of contents
|
||||||
enableTocSwitch = true # single page table of contents visibility switch
|
enableTocSwitch = true # single page table of contents visibility switch
|
||||||
itemsPerCategory = 5 # maximum number of posts shown in the sidebar.
|
itemsPerCategory = 5 # maximum number of posts shown in the sidebar.
|
||||||
searchLanguages = ['en'] # lunr multilanguage search. https://github.com/MihaiValentin/lunr-languages
|
|
||||||
|
|
||||||
# footer
|
# footer
|
||||||
showPoweredBy = true # show footer text: Powered by Hugo and Zzo theme
|
showPoweredBy = true # show footer text: Powered by Hugo and Zzo theme
|
||||||
|
|
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
|
@ -223,7 +223,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&--desc {
|
&--desc {
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
|
@include truncate(960px);
|
||||||
@include themify($themes) {
|
@include themify($themes) {
|
||||||
color: themed('search-color');
|
color: themed('search-color');
|
||||||
opacity: 0.65;
|
opacity: 0.65;
|
||||||
|
|
114
data/lib.toml
114
data/lib.toml
|
@ -112,117 +112,3 @@
|
||||||
[reveal.plugin.highlight]
|
[reveal.plugin.highlight]
|
||||||
sri = "sha256-ZksQEvQYWeyyAZ67Oi6Ob1eLnb1IpmIV+IGstqKyxgw="
|
sri = "sha256-ZksQEvQYWeyyAZ67Oi6Ob1eLnb1IpmIV+IGstqKyxgw="
|
||||||
url = "https://cdn.jsdelivr.net/npm/reveal.js@3.8.0/plugin/highlight/highlight.js"
|
url = "https://cdn.jsdelivr.net/npm/reveal.js@3.8.0/plugin/highlight/highlight.js"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# lunr languages
|
|
||||||
[js.stemmer]
|
|
||||||
code = "stemmer"
|
|
||||||
sri = "sha256-LnITYFhGoYAU7HUJEMsYqKTGC7IyABA7P62e8nsQxwU="
|
|
||||||
url = "https://cdn.jsdelivr.net/npm/lunr-languages@1.4.0/min/lunr.stemmer.support.min.js"
|
|
||||||
|
|
||||||
[js.multi_language]
|
|
||||||
code = "multiLanguage"
|
|
||||||
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"
|
|
|
@ -1,28 +1,48 @@
|
||||||
baseURL = "http://example.org/"
|
baseURL = ""
|
||||||
title = "Hugo Zzo Theme"
|
|
||||||
theme = "zzo"
|
theme = "zzo"
|
||||||
|
|
||||||
defaultContentLanguage = "en"
|
defaultContentLanguage = "ko"
|
||||||
defaultContentLanguageInSubdir = true
|
defaultContentLanguageInSubdir = true
|
||||||
hasCJKLanguage = true
|
hasCJKLanguage = true
|
||||||
|
|
||||||
summaryLength = 70
|
summaryLength = 70
|
||||||
|
|
||||||
copyright = "©{year}, All Rights Reserved"
|
copyright = "©{year}, ZZOSSIG All Rights Reserved"
|
||||||
timeout = 10000
|
timeout = 10000
|
||||||
enableEmoji = true
|
enableEmoji = true
|
||||||
paginate = 13
|
paginate = 13
|
||||||
rssLimit = 100
|
rssLimit = 100
|
||||||
|
|
||||||
pygmentsOptions = "linenos=table"
|
|
||||||
pygmentsUseClasses = true
|
|
||||||
|
|
||||||
googleAnalytics = ""
|
googleAnalytics = ""
|
||||||
|
|
||||||
[markup]
|
[markup]
|
||||||
[markup.goldmark]
|
[markup.goldmark]
|
||||||
|
[markup.goldmark.extensions]
|
||||||
|
definitionList = true
|
||||||
|
footnote = true
|
||||||
|
linkify = true
|
||||||
|
strikethrough = true
|
||||||
|
table = true
|
||||||
|
taskList = true
|
||||||
|
typographer = true
|
||||||
|
[markup.goldmark.parser]
|
||||||
|
attribute = true
|
||||||
|
autoHeadingID = true
|
||||||
[markup.goldmark.renderer]
|
[markup.goldmark.renderer]
|
||||||
|
hardWraps = true
|
||||||
unsafe = true
|
unsafe = true
|
||||||
|
xHTML = true
|
||||||
|
[markup.highlight]
|
||||||
|
codeFences = true
|
||||||
|
hl_Lines = ""
|
||||||
|
lineNoStart = 1
|
||||||
|
lineNos = true
|
||||||
|
lineNumbersInTable = true
|
||||||
|
noClasses = false
|
||||||
|
tabWidth = 4
|
||||||
|
[markup.tableOfContents]
|
||||||
|
endLevel = 3
|
||||||
|
startLevel = 2
|
||||||
|
|
||||||
[outputs]
|
[outputs]
|
||||||
home = ["HTML", "RSS", "JSON", "WEBMANIFEST"]
|
home = ["HTML", "RSS", "JSON", "WEBMANIFEST"]
|
||||||
|
@ -35,7 +55,7 @@ googleAnalytics = ""
|
||||||
baseName = "webmanifest"
|
baseName = "webmanifest"
|
||||||
mediaType = "application/manifest+json"
|
mediaType = "application/manifest+json"
|
||||||
rel = "manifest"
|
rel = "manifest"
|
||||||
|
|
||||||
[taxonomies]
|
[taxonomies]
|
||||||
category = "categories"
|
category = "categories"
|
||||||
tag = "tags"
|
tag = "tags"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
[en]
|
|
||||||
title = "Hugo Zzo Theme"
|
|
||||||
languageName = "English"
|
|
||||||
weight = 1
|
|
||||||
|
|
||||||
[ko]
|
[ko]
|
||||||
title = "Hugo Zzo Theme"
|
title = "쪼식이 블로그"
|
||||||
languageName = "한국어"
|
languageName = "한국어"
|
||||||
|
weight = 1
|
||||||
|
|
||||||
|
[en]
|
||||||
|
title = "Zzossig's Blog"
|
||||||
|
languageName = "English"
|
||||||
weight = 2
|
weight = 2
|
||||||
|
|
|
@ -10,12 +10,6 @@
|
||||||
url = "archive"
|
url = "archive"
|
||||||
weight = 2
|
weight = 2
|
||||||
|
|
||||||
[[main]]
|
|
||||||
identifier = "pt"
|
|
||||||
name = "pt"
|
|
||||||
url = "pt"
|
|
||||||
weight = 3
|
|
||||||
|
|
||||||
[[main]]
|
[[main]]
|
||||||
identifier = "gallery"
|
identifier = "gallery"
|
||||||
name = "gallery"
|
name = "gallery"
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
[[main]]
|
||||||
|
identifier = "about"
|
||||||
|
name = "어바웃"
|
||||||
|
url = "about"
|
||||||
|
weight = 1
|
||||||
|
|
||||||
|
[[main]]
|
||||||
|
identifier = "archive"
|
||||||
|
name = "아카이브"
|
||||||
|
url = "archive"
|
||||||
|
weight = 2
|
||||||
|
|
||||||
|
[[main]]
|
||||||
|
identifier = "gallery"
|
||||||
|
name = "갤러리"
|
||||||
|
url = "gallery"
|
||||||
|
weight = 3
|
||||||
|
|
||||||
|
[[main]]
|
||||||
|
parent = "gallery"
|
||||||
|
name = "fiverr"
|
||||||
|
url = "gallery/mine"
|
||||||
|
|
||||||
|
[[main]]
|
||||||
|
identifier = "posts"
|
||||||
|
name = "포스트"
|
||||||
|
url = "posts"
|
||||||
|
weight = 4
|
||||||
|
|
||||||
|
[[main]]
|
||||||
|
identifier = "notes"
|
||||||
|
name = "노트"
|
||||||
|
url = "notes"
|
||||||
|
weight = 5
|
|
@ -1,5 +1,5 @@
|
||||||
logoText = "Zzo"
|
logoText = ""
|
||||||
description = "The Zzo theme for Hugo example site."
|
description = "쪼식이 블로그"
|
||||||
custom_css = []
|
custom_css = []
|
||||||
custom_js = []
|
custom_js = []
|
||||||
|
|
||||||
|
@ -18,12 +18,12 @@ archivePaginate = 13
|
||||||
paginateWindow = 1
|
paginateWindow = 1
|
||||||
|
|
||||||
# whoami
|
# whoami
|
||||||
myname = "zzossig"
|
myname = "최성환"
|
||||||
email = "zzossig@gmail.com"
|
email = "zzossig@gmail.com"
|
||||||
whoami = "Web Developer"
|
whoami = "성장중인 프로그래머"
|
||||||
useGravatar = false
|
useGravatar = true
|
||||||
location = "Seoul, Korea"
|
location = "Seoul, Korea"
|
||||||
organization = "Hugo"
|
organization = ""
|
||||||
link = "https://github.com/zzossig/hugo-theme-zzo"
|
link = "https://github.com/zzossig/hugo-theme-zzo"
|
||||||
|
|
||||||
# sidebar
|
# sidebar
|
||||||
|
@ -35,7 +35,6 @@ enableSidebarCategories = true
|
||||||
enableToc = true
|
enableToc = true
|
||||||
enableTocSwitch = true
|
enableTocSwitch = true
|
||||||
itemsPerCategory = 5
|
itemsPerCategory = 5
|
||||||
searchLanguages = ['en']
|
|
||||||
|
|
||||||
# footer
|
# footer
|
||||||
showPoweredBy = true
|
showPoweredBy = true
|
||||||
|
@ -43,7 +42,7 @@ showFeedLinks = true
|
||||||
showSocialLinks = true
|
showSocialLinks = true
|
||||||
enableLangChange = true
|
enableLangChange = true
|
||||||
enableThemeChange = true
|
enableThemeChange = true
|
||||||
themeOptions = ["dark", "light", "hacker", "solarized", "custom"]
|
themeOptions = ["light", "dark", "hacker", "solarized", "custom"]
|
||||||
|
|
||||||
# service
|
# service
|
||||||
baiduAnalytics = ""
|
baiduAnalytics = ""
|
||||||
|
@ -100,11 +99,11 @@ commento = false
|
||||||
dataAttrs = "" # "data-isso='https://isso.example.com' data-isso-require-author='true'"
|
dataAttrs = "" # "data-isso='https://isso.example.com' data-isso-require-author='true'"
|
||||||
|
|
||||||
[socialOptions]
|
[socialOptions]
|
||||||
email = "mailto:your@email.com"
|
email = "mailto:zzossig@gmail.com"
|
||||||
facebook = "http://example.org/"
|
facebook = ""
|
||||||
twitter = "http://example.org/"
|
twitter = "https://twitter.com/zzossig"
|
||||||
github = "https://github.com/zzossig/hugo-theme-zzo"
|
github = "https://github.com/zzossig/hugo-theme-zzo"
|
||||||
stack-overflow = ""
|
stack-overflow = "https://stackoverflow.com/users/11747951/zzossig"
|
||||||
instagram = ""
|
instagram = ""
|
||||||
google-plus = ""
|
google-plus = ""
|
||||||
youtube = ""
|
youtube = ""
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -8,52 +8,40 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $fuse := resources.Get "js/fuse.min.js" | resources.Fingerprint }}
|
||||||
|
<script defer src="{{ $fuse.RelPermalink }}"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// search
|
// search
|
||||||
var runSearch = function() {
|
var runSearch = function() {
|
||||||
{{ $searchLanguages := .Site.Params.searchLanguages }}
|
|
||||||
var searchLanguages = JSON.parse({{ $searchLanguages | jsonify }});
|
|
||||||
{{ if .Site.IsMultiLingual }}
|
{{ if .Site.IsMultiLingual }}
|
||||||
var baseurl = "{{.Site.BaseURL}}{{.Site.LanguagePrefix}}";
|
var baseurl = "{{.Site.BaseURL}}{{.Site.LanguagePrefix}}";
|
||||||
{{ else }}
|
{{ else }}
|
||||||
var baseurl = "{{.Site.BaseURL}}";
|
var baseurl = "{{.Site.BaseURL}}";
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
if (!searchLanguages) {
|
|
||||||
searchLanguages = ['en'];
|
|
||||||
}
|
|
||||||
|
|
||||||
var lunrIndex = null;
|
|
||||||
var pagesIndex = null;
|
|
||||||
var searchResults = null;
|
var searchResults = null;
|
||||||
var searchMenu = null;
|
var searchMenu = null;
|
||||||
|
var fuse = null;
|
||||||
|
|
||||||
function endsWith(str, suffix) {
|
function endsWith(str, suffix) {
|
||||||
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function initLunr() {
|
function initFuse() {
|
||||||
if (!endsWith(baseurl, "/")) {
|
if (!endsWith(baseurl, "/")) {
|
||||||
baseurl = baseurl + '/';
|
baseurl = baseurl + '/';
|
||||||
};
|
};
|
||||||
|
|
||||||
$.getJSON(baseurl + "index.json")
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: baseurl + "index.json",
|
||||||
|
contentType: "application/json; charset=utf-8",
|
||||||
|
dataType: "json",
|
||||||
|
})
|
||||||
.done(function (index) {
|
.done(function (index) {
|
||||||
pagesIndex = index;
|
fuse = new Fuse(index, {
|
||||||
lunrIndex = lunr(function () {
|
keys: ['title', 'description', 'content']
|
||||||
this.use(lunr.multiLanguage(...searchLanguages));
|
|
||||||
this.ref('uri');
|
|
||||||
this.field('title');
|
|
||||||
this.field('description');
|
|
||||||
this.field('content');
|
|
||||||
//this.field('tags');
|
|
||||||
//this.field('series');
|
|
||||||
//this.field('categories');
|
|
||||||
|
|
||||||
var that = this;
|
|
||||||
index.forEach(function (page) {
|
|
||||||
that.add(page);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.fail(function (jqxhr, textStatus, error) {
|
.fail(function (jqxhr, textStatus, error) {
|
||||||
|
@ -62,14 +50,6 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function search(query) {
|
|
||||||
return lunrIndex.search(query).map(function (result) {
|
|
||||||
return pagesIndex.filter(function (page) {
|
|
||||||
return page.uri === result.ref;
|
|
||||||
})[0];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderSearchResults(results) {
|
function renderSearchResults(results) {
|
||||||
searchResults = document.getElementById('search-results');
|
searchResults = document.getElementById('search-results');
|
||||||
searchMenu = document.getElementById('search-menu');
|
searchMenu = document.getElementById('search-menu');
|
||||||
|
@ -123,7 +103,7 @@
|
||||||
searchResults.appendChild(content);
|
searchResults.appendChild(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
initLunr();
|
initFuse();
|
||||||
|
|
||||||
$("#search").on('input', function (e) {
|
$("#search").on('input', function (e) {
|
||||||
if (!e.target.value) {
|
if (!e.target.value) {
|
||||||
|
@ -135,7 +115,7 @@
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = search(e.target.value);
|
var results = fuse.search(e.target.value);
|
||||||
renderSearchResults(results);
|
renderSearchResults(results);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -156,7 +136,7 @@
|
||||||
$('#search-results').attr('class', 'dropdown');
|
$('#search-results').attr('class', 'dropdown');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var results = search(e.target.value);
|
var results = fuse.search(e.target.value);
|
||||||
renderSearchResults(results);
|
renderSearchResults(results);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -186,7 +166,7 @@
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = search(e.target.value);
|
var results = fuse.search(e.target.value);
|
||||||
renderSearchResultsMobile(results);
|
renderSearchResultsMobile(results);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,20 +11,4 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ $lunr := resources.Get "js/lunr.min.js" | resources.Fingerprint }}
|
|
||||||
<script defer src="{{ $lunr.RelPermalink }}"></script>
|
|
||||||
|
|
||||||
{{ $stemmer := .Site.Data.lib.js.stemmer }}
|
|
||||||
<script defer src="{{ $stemmer.url }}" integrity="{{ $stemmer.sri }}" crossorigin="anonymous"></script>
|
|
||||||
|
|
||||||
{{ $multi := .Site.Data.lib.js.multi_language }}
|
|
||||||
<script defer src="{{ $multi.url }}" integrity="{{ $multi.sri }}" crossorigin="anonymous"></script>
|
|
||||||
|
|
||||||
{{ $searchLanguages := .Site.Params.searchLanguages }}
|
|
||||||
{{ range .Site.Data.lib.lunr }}
|
|
||||||
{{ if in $searchLanguages .code }}
|
|
||||||
<script defer src="{{ .url }}" integrity="{{ .sri }}" crossorigin="anonymous"></script>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
Loading…
Reference in New Issue