feat(search): add local search (#231)

* feat(search): add local search

* docs: add docs for search
This commit is contained in:
Dillon
2020-04-15 15:46:50 +08:00
committed by GitHub
parent b6ce753ae7
commit 90184ca3e7
92 changed files with 4843 additions and 1214 deletions

View File

@@ -33,19 +33,10 @@
</head>
<body>
{{- /* Check theme isDark before body rendering */ -}}
<script>
if (!window.localStorage || !window.localStorage.getItem('theme')) {
{{- $theme := .Site.Params.defaultTheme -}}
{{- if eq $theme "auto" -}}
window.isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
{{- else -}}
window.isDark = '{{ $theme }}' === 'dark';
{{- end -}}
} else {
window.isDark = (window.localStorage && window.localStorage.getItem('theme')) === 'dark';
}
window.isDark && document.body.classList.add('dark-theme');
</script>
{{- $theme := .Site.Params.defaultTheme -}}
<script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('{{ .Site.Params.defaultTheme }}' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '{{ .Site.Params.defaultTheme }}' === 'dark')) && document.body.classList.add('dark');</script>
<div id="mask"></div>
{{- /* Body wrapper */ -}}
<div class="wrapper">
@@ -60,12 +51,12 @@
<div id="fixed-buttons" class="animated faster">
{{- /* top button */ -}}
<a href="#" id="top-button" class="fixed-button" title="{{ T `backToTop` }}">
<a href="#" id="back-to-top" class="fixed-button" title="{{ T `backToTop` }}">
<i class="fas fa-arrow-up fa-fw"></i>
</a>
{{- /* comment button */ -}}
<a href="#" id="comment-button" class="fixed-button" title="{{ T `viewComments` }}">
<a href="#" id="view-comments" class="fixed-button" title="{{ T `viewComments` }}">
<i class="fas fa-comment fa-fw"></i>
</a>
</div>

View File

@@ -12,7 +12,7 @@
{{- /* Content */ -}}
<div class="content" id="content">
{{- partial "single/content.html" .Content -}}
{{- partial "function/content.html" .Content | safeHTML -}}
</div>
</div>
{{- end -}}

View File

@@ -45,7 +45,7 @@
{{- /* Summary content */ -}}
<div class="content">
{{- with .Summary -}}
{{- partial "single/content.html" . -}}
{{- partial "function/content.html" . | safeHTML -}}
{{- else -}}
{{- .Description | safeHTML -}}
{{- end -}}