mirror of
https://github.com/dillonzq/LoveIt.git
synced 2025-03-13 19:27:47 +01:00
feat(search): add local search (#231)
* feat(search): add local search * docs: add docs for search
This commit is contained in:
parent
b6ce753ae7
commit
90184ca3e7
92 changed files with 4843 additions and 1214 deletions
20
README.md
20
README.md
|
@ -32,9 +32,10 @@ Compared to the original LeaveIt theme and the KeepIt theme, the LoveIt theme ha
|
|||
* Some beautiful **CSS animations**
|
||||
* Easy-to-use and self-expanding **table of contents**
|
||||
* More **social links**, **share sites** and **comment system**
|
||||
* Extended markdown syntax for **[Font Awesome](https://fontawesome.com/) icons**
|
||||
* Extended markdown syntax for **ruby annotation**
|
||||
* Extended markdown syntax for **fraction**
|
||||
* **Search** supported by [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/)
|
||||
* Extended Markdown syntax for **[Font Awesome](https://fontawesome.com/) icons**
|
||||
* Extended Markdown syntax for **ruby annotation**
|
||||
* Extended Markdown syntax for **fraction**
|
||||
* **Mathematical formula** supported by [KaTeX](https://katex.org/)
|
||||
* **Diagram syntax** shortcode supported by [mermaid](https://github.com/knsv/mermaid)
|
||||
* **Interactive data visualization** shortcode supported by [ECharts](https://echarts.apache.org/)
|
||||
|
@ -89,11 +90,12 @@ I hope you will LoveIt ❤️!
|
|||
|
||||
### Extended Features
|
||||
|
||||
* **Search** supported by [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/)
|
||||
* Automatically **highlighting** code
|
||||
* **Images gallery** supported by [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
|
||||
* Extended markdown syntax for **[Font Awesome](https://fontawesome.com/) icons**
|
||||
* Extended markdown syntax for **ruby annotation**
|
||||
* Extended markdown syntax for **fraction**
|
||||
* Extended Markdown syntax for **[Font Awesome](https://fontawesome.com/) icons**
|
||||
* Extended Markdown syntax for **ruby annotation**
|
||||
* Extended Markdown syntax for **fraction**
|
||||
* **Mathematical formula** supported by [KaTeX](https://katex.org/)
|
||||
* **Diagrams** shortcode supported by [mermaid](https://github.com/knsv/mermaid)
|
||||
* **Interactive data visualization** shortcode supported by [ECharts](https://echarts.apache.org/)
|
||||
|
@ -128,9 +130,13 @@ Thanks to the authors of following resources included in the theme:
|
|||
* [Font Awesome](https://fontawesome.com/)
|
||||
* [Fork Awesome](https://forkaweso.me/Fork-Awesome/)
|
||||
* [Animate.css](https://daneden.github.io/animate.css/)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [autocomplete.js](https://github.com/algolia/autocomplete.js)
|
||||
* [Lunr.js](https://lunrjs.com/)
|
||||
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
|
||||
* [Sharer.js](https://github.com/ellisonleao/sharer.js)
|
||||
* [lazysizes](https://github.com/aFarkas/lazysizes)
|
||||
* [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [TypeIt](https://typeitjs.com/)
|
||||
* [KaTeX](https://katex.org/)
|
||||
* [mermaid](https://github.com/knsv/mermaid)
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
* 一些美观的 **CSS 动画**
|
||||
* 易用和自动展开的**文章目录**
|
||||
* 支持更多的**社交链接**、**网站分享**和**评论系统**
|
||||
* 支持基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/) 的**搜索**
|
||||
* 支持基于 **[Font Awesome](https://fontawesome.com/) 图标**的扩展 Markdown 语法
|
||||
* 支持**上标注释**的扩展 Markdown 语法
|
||||
* 支持**分数**的扩展 Markdown 语法
|
||||
|
@ -84,6 +85,7 @@
|
|||
|
||||
### 扩展功能
|
||||
|
||||
* 支持基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/) 的**搜索**
|
||||
* 支持**代码高亮**
|
||||
* 支持基于 [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js) 的**图片画廊**
|
||||
* 支持 **[Font Awesome](https://fontawesome.com/) 图标**的扩展 Markdown 语法
|
||||
|
@ -123,9 +125,13 @@ LoveIt 主题中用到了以下项目,感谢它们的作者:
|
|||
* [Font Awesome](https://fontawesome.com/)
|
||||
* [Fork Awesome](https://forkaweso.me/Fork-Awesome/)
|
||||
* [Animate.css](https://daneden.github.io/animate.css/)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [autocomplete.js](https://github.com/algolia/autocomplete.js)
|
||||
* [Lunr.js](https://lunrjs.com/)
|
||||
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
|
||||
* [Sharer.js](https://github.com/ellisonleao/sharer.js)
|
||||
* [lazysizes](https://github.com/aFarkas/lazysizes)
|
||||
* [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [TypeIt](https://typeitjs.com/)
|
||||
* [KaTeX](https://katex.org/)
|
||||
* [mermaid](https://github.com/knsv/mermaid)
|
||||
|
|
|
@ -12,6 +12,7 @@ license: ""
|
|||
tags: []
|
||||
categories: []
|
||||
hiddenFromHomePage: false
|
||||
hiddenFromSearch: false
|
||||
|
||||
featuredImage: ""
|
||||
featuredImagePreview: ""
|
||||
|
|
|
@ -9,8 +9,8 @@ html {
|
|||
|
||||
/* scrollbar, only support webkit */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
width: .5rem;
|
||||
height: .5rem;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
|
@ -22,44 +22,26 @@ html {
|
|||
}
|
||||
|
||||
::selection {
|
||||
background: $selection-color;
|
||||
background-color: $selection-color;
|
||||
|
||||
.dark-theme & {
|
||||
background: $selection-color-dark;
|
||||
.dark & {
|
||||
background-color: $selection-color-dark;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
-webkit-font-smoothing: subpixel-antialiased;
|
||||
background-color: $global-background-color;
|
||||
color: $global-font-color;
|
||||
overflow-wrap: break-word;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
opacity: 0.05;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: -1;
|
||||
-webkit-filter: grayscale(100%);
|
||||
-moz-filter: grayscale(100%);
|
||||
-ms-filter: grayscale(100%);
|
||||
-o-filter: grayscale(100%);
|
||||
filter: grayscale(100%);
|
||||
filter: gray;
|
||||
}
|
||||
|
||||
&.dark-theme {
|
||||
&.dark {
|
||||
color: $global-font-color-dark;
|
||||
background-color: $global-background-color-dark;
|
||||
}
|
||||
}
|
||||
|
||||
@import "../_partial/mask";
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
|
|
@ -14,11 +14,3 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
height: 2rem;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
line-height: 1.5rem;
|
||||
padding-top: 2rem;
|
||||
}
|
||||
|
|
|
@ -11,16 +11,16 @@
|
|||
}
|
||||
|
||||
@media only screen and (max-width: 960px) {
|
||||
#toc-auto {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#toc-static {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.page {
|
||||
max-width: 80%;
|
||||
|
||||
#toc-auto {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#toc-static {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,10 @@
|
|||
display: block;
|
||||
}
|
||||
|
||||
body.blur {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.page {
|
||||
max-width: 100%;
|
||||
padding-top: $page-padding-top-mobile;
|
||||
|
|
5
assets/css/_mixin/_blur.scss
Normal file
5
assets/css/_mixin/_blur.scss
Normal file
|
@ -0,0 +1,5 @@
|
|||
@mixin blur {
|
||||
.blur & {
|
||||
@include filter(blur(1.5px));
|
||||
}
|
||||
}
|
69
assets/css/_mixin/_compatibility.scss
Normal file
69
assets/css/_mixin/_compatibility.scss
Normal file
|
@ -0,0 +1,69 @@
|
|||
@mixin border-radius($value) {
|
||||
-webkit-border-radius: $value;
|
||||
-moz-border-radius: $value;
|
||||
border-radius: $value;
|
||||
}
|
||||
|
||||
@mixin box-shadow($value) {
|
||||
-webkit-box-shadow: $value;
|
||||
box-shadow: $value;
|
||||
}
|
||||
|
||||
@mixin transition($values...) {
|
||||
-webkit-transition: $values;
|
||||
-moz-transition: $values;
|
||||
-o-transition: $values;
|
||||
transition: $values;
|
||||
}
|
||||
|
||||
@mixin transform($value) {
|
||||
-webkit-transform: $value;
|
||||
-moz-transform: $value;
|
||||
-ms-transform: $value;
|
||||
-o-transform: $value;
|
||||
transform: $value;
|
||||
}
|
||||
|
||||
@mixin filter($value) {
|
||||
-webkit-filter: $value;
|
||||
-moz-filter: $value;
|
||||
-ms-filter: $value;
|
||||
filter: $value;
|
||||
}
|
||||
|
||||
@mixin flex($value) {
|
||||
-webkit-flex: $value;
|
||||
flex: $value;
|
||||
}
|
||||
|
||||
@mixin box($orient) {
|
||||
display: -moz-box;
|
||||
display: -webkit-box;
|
||||
display: box;
|
||||
|
||||
-moz-box-orient: $orient;
|
||||
-webkit-box-orient: $orient;
|
||||
box-orient: $orient;
|
||||
}
|
||||
|
||||
@mixin placeholder($color) {
|
||||
input::-webkit-input-placeholder{
|
||||
color: $color;
|
||||
}
|
||||
|
||||
input:-moz-placeholder{
|
||||
color: $color;
|
||||
}
|
||||
|
||||
input::-moz-placeholder{
|
||||
color: $color;
|
||||
}
|
||||
|
||||
input:-ms-input-placeholder{
|
||||
color: $color;
|
||||
}
|
||||
|
||||
input::placeholder {
|
||||
color: $color;
|
||||
}
|
||||
}
|
|
@ -1,2 +1,4 @@
|
|||
@import "_compatibility";
|
||||
@import "_link";
|
||||
@import "_blur";
|
||||
@import "_summary";
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
a {
|
||||
color: if($light, $global-link-color, $single-link-color);
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: if($dark, $global-link-color-dark, $single-link-color-dark);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
|||
&:hover {
|
||||
color: if($light, $global-link-hover-color, $single-link-hover-color);
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: if($dark, $global-link-hover-color-dark, $single-link-hover-color-dark);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
color: $global-font-color;
|
||||
border-bottom: 1px dashed $global-border-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-color-dark;
|
||||
border-bottom: 1px dashed $global-border-color-dark;
|
||||
}
|
||||
|
@ -33,10 +33,7 @@
|
|||
}
|
||||
|
||||
.content {
|
||||
display: -moz-box;
|
||||
display: -webkit-box;
|
||||
-moz-box-orient: vertical;
|
||||
-webkit-box-orient: vertical;
|
||||
@include box(vertical);
|
||||
-webkit-line-clamp: 3;
|
||||
margin-top: .3rem;
|
||||
width: 100%;
|
||||
|
@ -45,7 +42,7 @@
|
|||
overflow-wrap: break-word;
|
||||
color: $global-font-secondary-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
|
||||
|
@ -76,7 +73,7 @@
|
|||
margin-right: .3125rem;
|
||||
color: $global-link-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-link-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +90,7 @@
|
|||
@include link(true, true);
|
||||
|
||||
b, strong {
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#content-404 {
|
||||
font-size: 1.8rem;
|
||||
line-height: 3rem;
|
||||
transform: translateY(30vh);
|
||||
@include transform(translateY(30vh));
|
||||
text-align: center;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
/** Home **/
|
||||
@mixin page-home($profile, $posts) {
|
||||
.home {
|
||||
@if $profile {
|
||||
.home-profile {
|
||||
-webkit-transform: translateY(if($posts, 0, 16vh));
|
||||
-moz-transform: translateY(if($posts, 0, 16vh));
|
||||
-ms-transform: translateY(if($posts, 0, 16vh));
|
||||
-o-transform: translateY(if($posts, 0, 16vh));
|
||||
transform: translateY(if($posts, 0, 16vh));
|
||||
@include transform(translateY(if($posts, 0, 16vh)));
|
||||
padding: if($posts, 2rem, 0) 0 .5rem;
|
||||
text-align: center;
|
||||
|
||||
|
@ -15,27 +10,18 @@
|
|||
padding: 0.6rem;
|
||||
|
||||
img {
|
||||
display: inline-block;
|
||||
width: if($posts, 6rem, 8rem);
|
||||
height: auto;
|
||||
display: inline-block;
|
||||
-webkit-border-radius: 100%;
|
||||
border-radius: 100%;
|
||||
-webkit-box-shadow: 0 0 0 0.3618em rgba(0, 0, 0, 0.05);
|
||||
box-shadow: 0 0 0 0.3618em rgba(0, 0, 0, 0.05);
|
||||
margin: 0 auto;
|
||||
-webkit-transition: all ease 0.4s;
|
||||
-moz-transition: all ease 0.4s;
|
||||
-o-transition: all ease 0.4s;
|
||||
transition: all ease 0.4s;
|
||||
@include border-radius(100%);
|
||||
@include box-shadow(0 0 0 .3618em rgba(0, 0, 0, .05));
|
||||
@include transition(all 0.4s ease);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
position: relative;
|
||||
-webkit-transform: translateY(-0.75rem);
|
||||
-moz-transform: translateY(-0.75rem);
|
||||
-ms-transform: translateY(-0.75rem);
|
||||
-o-transform: translateY(-0.75rem);
|
||||
transform: translateY(-0.75rem);
|
||||
@include transform(translateY(-.75rem));
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +56,7 @@
|
|||
padding: .4rem;
|
||||
color: $global-font-secondary-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
max-width: 60%;
|
||||
margin: 0 auto;
|
||||
padding-top: $page-padding-top-desktop;
|
||||
|
||||
@include blur;
|
||||
}
|
||||
|
||||
@import "_single";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/** Single **/
|
||||
@import "../_partial/_single/toc";
|
||||
|
||||
.single {
|
||||
.single-title {
|
||||
margin: 1rem 0 .5rem;
|
||||
|
@ -22,7 +23,7 @@
|
|||
display: inline-block;
|
||||
}
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
|
||||
|
@ -45,8 +46,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
@import "../_partial/_single/toc";
|
||||
|
||||
.content {
|
||||
> h2 {
|
||||
font-size: 1.5rem;
|
||||
|
@ -88,7 +87,7 @@
|
|||
font-weight: bold;
|
||||
margin: 1.2rem 0;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
font-weight: bolder;
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +102,7 @@
|
|||
margin-right: .3125rem;
|
||||
color: $single-link-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $single-link-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +119,7 @@
|
|||
b, strong {
|
||||
font-weight: bold;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: #ddd;
|
||||
}
|
||||
}
|
||||
|
@ -131,12 +130,12 @@
|
|||
word-break: break-all;
|
||||
word-break: break-word;
|
||||
|
||||
.dark-theme & b, .dark-theme & strong {
|
||||
.dark & b, .dark & strong {
|
||||
color: $single-link-color-dark;
|
||||
}
|
||||
}
|
||||
|
||||
.dark-theme a:hover b, .dark-theme a:hover strong {
|
||||
.dark a:hover b, .dark a:hover strong {
|
||||
color: $single-link-hover-color-dark;
|
||||
}
|
||||
|
||||
|
@ -153,7 +152,7 @@
|
|||
color: $global-font-secondary-color;
|
||||
}
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background: $code-background-color-dark;
|
||||
|
||||
rt {
|
||||
|
@ -168,7 +167,7 @@
|
|||
&::-webkit-scrollbar {
|
||||
background-color: $table-background-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background-color: $table-background-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -181,14 +180,14 @@
|
|||
background: $table-background-color;
|
||||
border-collapse: collapse;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background: $table-background-color-dark;
|
||||
}
|
||||
|
||||
thead {
|
||||
background: $table-thead-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background-color: $table-thead-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +196,7 @@
|
|||
padding: .3rem 1rem;
|
||||
border: 1px double $global-border-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
border: 1px double $global-border-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -249,14 +248,14 @@
|
|||
position: absolute;
|
||||
top: 0em;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
@include transform(translate(-50%, -50%));
|
||||
width: 3rem;
|
||||
height: 2rem;
|
||||
font: 6em/1.08em 'PT Sans', sans-serif;
|
||||
color: $single-link-color;
|
||||
text-align: center;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $single-link-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -268,12 +267,12 @@
|
|||
font-size: 0.875em;
|
||||
color: $single-link-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $single-link-color-dark;
|
||||
}
|
||||
}
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
border-color: $global-border-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +280,7 @@
|
|||
.footnotes {
|
||||
color: $global-font-secondary-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
|
||||
|
@ -304,7 +303,7 @@
|
|||
border-top: 1px dashed $global-border-color;
|
||||
border-bottom: none;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
border-top: 1px dashed $global-border-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -315,19 +314,17 @@
|
|||
background-color: $global-background-color;
|
||||
border: 1px solid $global-border-color;
|
||||
border-bottom-color: $global-border-color;
|
||||
border-radius: 3px;
|
||||
-webkit-box-shadow: inset 0 -1px 0 $global-border-color;
|
||||
box-shadow: inset 0 -1px 0 $global-border-color;
|
||||
@include border-radius(3px);
|
||||
@include box-shadow(inset 0 -1px 0 $global-border-color);
|
||||
font-size: .8rem;
|
||||
font-family: $code-font-family;
|
||||
color: $code-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background-color: $global-background-color-dark;
|
||||
border: 1px solid $global-border-color-dark;
|
||||
border-bottom-color: $global-border-color-dark;
|
||||
-webkit-box-shadow: inset 0 -1px 0 $global-border-color-dark;
|
||||
box-shadow: inset 0 -1px 0 $global-border-color-dark;
|
||||
@include box-shadow(inset 0 -1px 0 $global-border-color-dark);
|
||||
color: $code-color-dark;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,25 +8,18 @@
|
|||
position: relative;
|
||||
margin: 5px 10px;
|
||||
overflow-wrap: break-word;
|
||||
-webkit-transition: all ease-out .3s;
|
||||
-moz-transition: all ease-out .3s;
|
||||
-o-transition: all ease-out .3s;
|
||||
transition: all ease-out .3s;
|
||||
@include transition(all ease-out 0.3s);
|
||||
|
||||
&:active,
|
||||
&:focus,
|
||||
&:hover {
|
||||
-webkit-transform: scale(1.2);
|
||||
-moz-transform: scale(1.2);
|
||||
-ms-transform: scale(1.2);
|
||||
-o-transform: scale(1.2);
|
||||
transform: scale(1.2);
|
||||
@include transform(scale(1.2));
|
||||
}
|
||||
|
||||
sup {
|
||||
color: $global-font-secondary-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
|
||||
.archive-item-link {
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
@ -55,15 +54,11 @@
|
|||
background-color: transparent;
|
||||
}
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-link-color-dark;
|
||||
text-decoration: none;
|
||||
transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, opacity 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
color: $global-link-hover-color-dark;
|
||||
text-decoration: none;
|
||||
transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, opacity 0.2s ease;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +68,7 @@
|
|||
text-align: right;
|
||||
color: $global-font-secondary-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
color: $global-font-secondary-color;
|
||||
background: $header-background-color;
|
||||
border: 1px solid darken($global-border-color, 10%);
|
||||
border-radius: 2rem;
|
||||
@include border-radius(2rem);
|
||||
|
||||
@include blur;
|
||||
|
||||
&:hover, &:active {
|
||||
color: $global-font-color;
|
||||
|
@ -24,7 +26,7 @@
|
|||
outline: none;
|
||||
}
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
background: $header-background-color-dark;
|
||||
border-color: darken($global-border-color-dark, 10%);
|
||||
|
@ -35,11 +37,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
#top-button {
|
||||
#back-to-top {
|
||||
display: block;
|
||||
bottom: 1.5rem;
|
||||
}
|
||||
|
||||
#comment-button {
|
||||
#view-comments {
|
||||
bottom: 4.5rem;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
/**Footer**/
|
||||
.copyright {
|
||||
font-size: .875rem;
|
||||
footer {
|
||||
height: 2rem;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
line-height: 1.5rem;
|
||||
padding-top: 2rem;
|
||||
|
||||
.copyright-line {
|
||||
width: 100%;
|
||||
.copyright {
|
||||
font-size: .875rem;
|
||||
|
||||
.icp-br {
|
||||
display: none;
|
||||
.copyright-line {
|
||||
width: 100%;
|
||||
|
||||
.icp-br {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@include blur;
|
||||
}
|
||||
|
|
|
@ -1,73 +1,169 @@
|
|||
header {
|
||||
width: 100%;
|
||||
z-index: 100;
|
||||
z-index: 150;
|
||||
background-color: $header-background-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background-color: $header-background-color-dark;
|
||||
}
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-family: $header-title-font-family;
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
.header-wrapper {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-family: $header-title-font-family;
|
||||
font-weight: bold;
|
||||
margin-right: .5rem;
|
||||
min-width: 10%;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
@include flex(10);
|
||||
}
|
||||
|
||||
.menu .menu-item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.language-select {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.menu .menu-item {
|
||||
position: relative;
|
||||
}
|
||||
.search {
|
||||
position: relative;
|
||||
|
||||
.language-select {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
input {
|
||||
color: transparent;
|
||||
box-sizing: border-box;
|
||||
height: 2.5rem;
|
||||
width: 2.5rem;
|
||||
@include border-radius(.5rem);
|
||||
border: none;
|
||||
outline: none;
|
||||
background-color: $header-background-color;
|
||||
vertical-align: baseline !important;
|
||||
@include transition(width 0.3s ease 0s);
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
.dark & {
|
||||
background-color: $header-background-color-dark;
|
||||
}
|
||||
}
|
||||
|
||||
.theme-switch i {
|
||||
-webkit-transform: rotate(225deg);
|
||||
-moz-transform: rotate(225deg);
|
||||
-ms-transform: rotate(225deg);
|
||||
-o-transform: rotate(225deg);
|
||||
transform: rotate(225deg);
|
||||
@include placeholder(transparent);
|
||||
|
||||
.search-button {
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
left: auto;
|
||||
right: 1rem;
|
||||
}
|
||||
|
||||
.search-toggle {
|
||||
left: .5rem;
|
||||
right: auto;
|
||||
}
|
||||
|
||||
.search-loading {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.search-clear {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.open &, &.mobile {
|
||||
input {
|
||||
color: $global-font-color;
|
||||
background-color: $search-background-color;
|
||||
padding: 0 2rem 0 2rem;
|
||||
}
|
||||
|
||||
.dark & {
|
||||
input {
|
||||
color: $global-font-color-dark;
|
||||
background-color: $search-background-color-dark;
|
||||
}
|
||||
|
||||
@include placeholder($global-font-secondary-color-dark);
|
||||
}
|
||||
|
||||
@include placeholder($global-font-secondary-color);
|
||||
|
||||
.search-button {
|
||||
color: $global-font-secondary-color;
|
||||
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
}
|
||||
|
||||
.search-clear:hover {
|
||||
color: #ff6b6b;
|
||||
}
|
||||
|
||||
.search-toggle:hover {
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.theme-switch i {
|
||||
@include transform(rotate(225deg));
|
||||
}
|
||||
|
||||
#header-desktop {
|
||||
display: block;
|
||||
position: $header-position-desktop;
|
||||
height: $header-height-desktop;
|
||||
line-height: $header-height-desktop;
|
||||
height: $header-height;
|
||||
line-height: $header-height;
|
||||
|
||||
.header-wrapper {
|
||||
width: auto;
|
||||
text-align: center;
|
||||
padding: 0 3%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 0 1.5rem;
|
||||
|
||||
.header-title {
|
||||
font-size: $header-title-font-size-desktop;
|
||||
max-width: 30%;
|
||||
}
|
||||
|
||||
.menu {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
|
||||
.menu-inner {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
margin: 0 .5rem;
|
||||
|
||||
&.theme-switch {
|
||||
margin: 0 .3rem;
|
||||
&.delimiter {
|
||||
border-left: 1.5px solid $global-font-color;
|
||||
|
||||
.dark & {
|
||||
border-left-color: $global-border-color-dark;
|
||||
}
|
||||
}
|
||||
|
||||
&.language {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
&.search {
|
||||
margin: 0 -.5rem 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,58 +171,56 @@ header {
|
|||
font-weight: 900;
|
||||
color: $header-hover-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $header-hover-color-dark;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.open .header-wrapper .menu .menu-item.search {
|
||||
margin: 0 .25rem 0 .5rem;
|
||||
|
||||
input {
|
||||
width: 24rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#header-mobile {
|
||||
display: none;
|
||||
position: $header-position-mobile;
|
||||
height: $header-height-mobile;
|
||||
line-height: $header-height-mobile;
|
||||
height: $header-height;
|
||||
line-height: $header-height;
|
||||
|
||||
.header-wrapper {
|
||||
.header-container {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
transition: all 0.3s ease 0s;
|
||||
|
||||
.header-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
.header-wrapper {
|
||||
padding: 0 1rem;
|
||||
font-size: 1.125rem;
|
||||
padding-right: 1rem;
|
||||
padding-left: 1rem;
|
||||
box-sizing: border-box;
|
||||
@include transition(margin-top 0.3s ease 0s);
|
||||
|
||||
.header-title {
|
||||
max-width: 80%;
|
||||
font-size: $header-title-font-size-mobile;
|
||||
max-width: 80%;
|
||||
}
|
||||
|
||||
.menu-toggle {
|
||||
cursor: pointer;
|
||||
line-height: 4rem;
|
||||
cursor: pointer;
|
||||
@include transition(width 0.3s ease 0s);
|
||||
|
||||
span {
|
||||
display: block;
|
||||
background: $global-font-color;
|
||||
width: 1.5rem;
|
||||
height: 2px;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
-webkit-transition: .1s margin .1s, .1s transform;
|
||||
-moz-transition: .1s margin .1s, .1s transform;
|
||||
-o-transition: .1s margin .1s, .1s transform;
|
||||
transition: .1s margin .1s, .1s transform;
|
||||
@include border-radius(3px);
|
||||
@include transition(all 0.3s ease-in-out);
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background: $global-font-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -140,19 +234,8 @@ header {
|
|||
}
|
||||
|
||||
&.active {
|
||||
span {
|
||||
-webkit-transition: .1s margin, .1s transform .1s;
|
||||
-moz-transition: .1s margin, .1s transform .1s;
|
||||
-o-transition: .1s margin, .1s transform .1s;
|
||||
transition: .1s margin, .1s transform .1s;
|
||||
}
|
||||
|
||||
span:nth-child(1) {
|
||||
-webkit-transform: rotate(45deg) translate(.4rem, .5rem);
|
||||
-moz-transform: rotate(45deg) translate(.4rem, .5rem);
|
||||
-ms-transform: rotate(45deg) translate(.4rem, .5rem);
|
||||
-o-transform: rotate(45deg) translate(.4rem, .5rem);
|
||||
transform: rotate(45deg) translate(.4rem, .5rem);
|
||||
@include transform(rotate(45deg) translate(.4rem, .5rem));
|
||||
}
|
||||
|
||||
span:nth-child(2) {
|
||||
|
@ -160,11 +243,7 @@ header {
|
|||
}
|
||||
|
||||
span:nth-child(3) {
|
||||
-moz-transform: rotate(-45deg) translate(.4rem, -.5rem);
|
||||
-ms-transform: rotate(-45deg) translate(.4rem, -.5rem);
|
||||
-webkit-transform: rotate(-45deg) translate(.4rem, -.5rem);
|
||||
-o-transform: rotate(-45deg) translate(.4rem, -.5rem);
|
||||
transform: rotate(-45deg) translate(.4rem, -.5rem);
|
||||
@include transform(rotate(-45deg) translate(.4rem, -.5rem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,12 +251,35 @@ header {
|
|||
|
||||
.menu {
|
||||
text-align: center;
|
||||
background: $global-background-color;
|
||||
border-top: 2px solid $global-font-color;
|
||||
background: $header-background-color;
|
||||
border-top: 2px solid $global-border-color;
|
||||
display: none;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1), 0px 4px 8px rgba(0, 0, 0, 0.1);
|
||||
padding-top: .5rem;
|
||||
@include box-shadow(0 .125rem .25rem rgba(0, 0, 0, .1));
|
||||
|
||||
a {
|
||||
.search-wrapper {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
padding: ($header-height - 2.5rem) / 2 1rem;
|
||||
line-height: 2.5rem;
|
||||
}
|
||||
|
||||
.search {
|
||||
flex-grow: 10;
|
||||
|
||||
.algolia-autocomplete, input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.search-cancel {
|
||||
display: none;
|
||||
margin-left: .75rem;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
display: block;
|
||||
line-height: 2.5rem;
|
||||
}
|
||||
|
@ -186,9 +288,149 @@ header {
|
|||
display: block;
|
||||
}
|
||||
|
||||
.dark-theme & {
|
||||
background: $global-background-color-dark;
|
||||
border-top: 2px solid $global-font-color-dark;
|
||||
.dark & {
|
||||
background: $header-background-color-dark;
|
||||
border-top-color: $global-border-color-dark;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.open {
|
||||
.header-wrapper {
|
||||
margin-top: -$header-height;
|
||||
}
|
||||
|
||||
.menu {
|
||||
padding-top: 0;
|
||||
border-top: none;
|
||||
|
||||
.menu-item {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.search-cancel {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.search-dropdown {
|
||||
position: fixed;
|
||||
z-index: 200;
|
||||
top: $header-height;
|
||||
@include box-shadow(0 .125rem .25rem rgba(0, 0, 0, .1));
|
||||
|
||||
&.desktop {
|
||||
right: 1.5rem;
|
||||
width: 30rem;
|
||||
}
|
||||
|
||||
&.mobile {
|
||||
right: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
right: 0 !important;
|
||||
background-color: $global-background-color;
|
||||
|
||||
.dark & {
|
||||
background-color: $global-background-color-dark;
|
||||
}
|
||||
|
||||
.suggestions {
|
||||
overflow-y: auto;
|
||||
max-height: calc(100vh - #{$header-height});
|
||||
|
||||
.suggestion {
|
||||
padding: .75rem 1rem;
|
||||
|
||||
.suggestion-title {
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 1rem;
|
||||
font-weight: bold;
|
||||
max-width: 75%;
|
||||
}
|
||||
|
||||
.suggestion-date {
|
||||
font-size: .875rem;
|
||||
float: right;
|
||||
text-align: right;
|
||||
color: $global-font-secondary-color;
|
||||
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
}
|
||||
|
||||
.suggestion-context {
|
||||
line-height: 1.25rem;
|
||||
@include box(vertical);
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
overflow-wrap: break-word;
|
||||
color: $global-font-secondary-color;
|
||||
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
}
|
||||
|
||||
em {
|
||||
font-style: normal;
|
||||
background-color: $selection-color;
|
||||
|
||||
.dark & {
|
||||
background-color: $selection-color-dark;
|
||||
}
|
||||
}
|
||||
|
||||
&.cursor {
|
||||
background: darken($code-background-color, 5%);
|
||||
|
||||
.dark & {
|
||||
background: lighten($code-background-color-dark, 5%);
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.search-empty {
|
||||
padding: 1rem;
|
||||
text-align: center;
|
||||
|
||||
.search-query {
|
||||
font-weight: bold;
|
||||
|
||||
.dark & {
|
||||
color: #ddd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.search-footer {
|
||||
padding: .5rem 1rem;
|
||||
float: right;
|
||||
font-size: .8rem;
|
||||
color: $global-font-secondary-color;
|
||||
|
||||
.dark {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
|
||||
@include link(false, false);
|
||||
|
||||
a {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
16
assets/css/_partial/_mask.scss
Normal file
16
assets/css/_partial/_mask.scss
Normal file
|
@ -0,0 +1,16 @@
|
|||
#mask {
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: -1;
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
|
||||
.blur & {
|
||||
z-index: 100;
|
||||
background-color: rgba(0, 0, 0, .25);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
/** pagination **/
|
||||
.pagination {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
@ -9,14 +8,13 @@
|
|||
padding: 1rem 0 0;
|
||||
|
||||
a {
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-size: .8rem;
|
||||
color: #bfbfbf;
|
||||
letter-spacing: .1rem;
|
||||
font-weight: 700;
|
||||
padding: 5px 5px;
|
||||
text-decoration: none;
|
||||
transition: 0.3s;
|
||||
@include transition(0.3s);
|
||||
}
|
||||
|
||||
li {
|
||||
|
@ -34,7 +32,7 @@
|
|||
color: $pagination-link-hover-color;
|
||||
}
|
||||
|
||||
.dark-theme &:hover a {
|
||||
.dark &:hover a {
|
||||
color: $pagination-link-hover-color-dark;
|
||||
}
|
||||
|
||||
|
@ -45,12 +43,12 @@
|
|||
width: 0;
|
||||
height: 3px;
|
||||
background: $pagination-link-hover-color;
|
||||
transition: 0.3s;
|
||||
@include transition(0.3s);
|
||||
bottom: 0px;
|
||||
}
|
||||
|
||||
.dark-theme &:before,
|
||||
.dark-theme &:after {
|
||||
.dark &:before,
|
||||
.dark &:after {
|
||||
background: $pagination-link-hover-color-dark;
|
||||
}
|
||||
|
||||
|
@ -80,7 +78,7 @@
|
|||
color: $pagination-link-hover-color;
|
||||
}
|
||||
|
||||
.dark-theme & a {
|
||||
.dark & a {
|
||||
color: $pagination-link-hover-color-dark;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ details.admonition {
|
|||
right: .5rem;
|
||||
color: $global-font-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,6 @@ details.admonition {
|
|||
|
||||
details.admonition[open] {
|
||||
i.details {
|
||||
transform: rotate(180deg);
|
||||
@include transform(rotate(180deg));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ code {
|
|||
padding: .2rem .4rem;
|
||||
color: $code-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $code-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ code {
|
|||
code, pre, .highlight table, .highlight tr, .highlight td {
|
||||
background: $code-background-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background: $code-background-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -27,14 +27,14 @@ code, pre, .highlight table, .highlight tr, .highlight td {
|
|||
|
||||
&::before {
|
||||
display: block;
|
||||
padding: .4rem;
|
||||
padding: .2rem .4rem;
|
||||
font-family: $global-font-family;
|
||||
font-weight: bold;
|
||||
color: $code-info-color;
|
||||
background: darken($code-background-color, 3%);
|
||||
content: 'Code';
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $code-info-color-dark;
|
||||
background: darken($code-background-color-dark, 3%);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ code, pre, .highlight table, .highlight tr, .highlight td {
|
|||
display: block;
|
||||
background-color: darken($code-background-color, 5%);
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background-color: darken($code-background-color-dark, 5%);
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ code, pre, .highlight table, .highlight tr, .highlight td {
|
|||
.ln, .lnt {
|
||||
color: $global-font-secondary-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ code, pre, .highlight table, .highlight tr, .highlight td {
|
|||
.#{$class} { color: $color; }
|
||||
}
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
@each $class, $color in $code-highlight-color-map-dark {
|
||||
.#{$class} { color: $color; }
|
||||
}
|
||||
|
@ -119,12 +119,12 @@ code, pre, .highlight table, .highlight tr, .highlight td {
|
|||
|
||||
@include link(false, false);
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background-color: darken($code-background-color-dark, 5%);
|
||||
}
|
||||
}
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
// imported from https://github.com/lonekorean/gist-syntax-themes/blob/master/stylesheets/one-dark.css
|
||||
.highlight {
|
||||
background: #141414;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
border-bottom: 1px solid $global-border-color;
|
||||
padding: 1rem 0 0.3rem;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
border-bottom: 1px solid $global-border-color-dark;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
|||
font-size: 0.8em;
|
||||
color: $global-font-secondary-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
|||
font-size: 0.8em;
|
||||
color: $global-font-secondary-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $global-font-secondary-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -68,10 +68,7 @@
|
|||
& a.next {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
-webkit-transition: all ease-out .3s;
|
||||
-moz-transition: all ease-out .3s;
|
||||
-o-transition: all ease-out .3s;
|
||||
transition: all ease-out .3s;
|
||||
@include transition(all 0.3s ease-out);
|
||||
}
|
||||
|
||||
& a.prev {
|
||||
|
@ -79,11 +76,7 @@
|
|||
}
|
||||
|
||||
& a.prev:hover {
|
||||
-webkit-transform: translateX(-4px);
|
||||
-moz-transform: translateX(-4px);
|
||||
-ms-transform: translateX(-4px);
|
||||
-o-transform: translateX(-4px);
|
||||
transform: translateX(-4px);
|
||||
@include transform(translateX(-4px));
|
||||
}
|
||||
|
||||
& a.next {
|
||||
|
@ -91,11 +84,7 @@
|
|||
}
|
||||
|
||||
& a.next:hover {
|
||||
-webkit-transform: translateX(4px);
|
||||
-moz-transform: translateX(4px);
|
||||
-ms-transform: translateX(4px);
|
||||
-o-transform: translateX(4px);
|
||||
transform: translateX(4px);
|
||||
@include transform(translateX(4px));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
iframe.instagram-media {
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
border: none !important;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
top: if($header-normal-mode-desktop, 5rem, 10rem);
|
||||
left: 10000px;
|
||||
|
||||
.dark-theme & {
|
||||
@include blur;
|
||||
|
||||
.dark & {
|
||||
border-left: 1px solid $global-border-color-dark;
|
||||
}
|
||||
|
||||
|
@ -39,7 +41,7 @@
|
|||
margin-right: .5rem;
|
||||
color: $single-link-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $single-link-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -58,14 +60,14 @@
|
|||
font-weight: bold;
|
||||
color: $single-link-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $single-link-color-dark;
|
||||
}
|
||||
|
||||
&::before {
|
||||
color: $single-link-hover-color;
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
color: $single-link-hover-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +84,7 @@
|
|||
list-style: none;
|
||||
background: darken($code-background-color, 3%);
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background: darken($code-background-color-dark, 3%);
|
||||
}
|
||||
|
||||
|
@ -111,7 +113,7 @@
|
|||
|
||||
details[open] {
|
||||
i.details {
|
||||
transform: rotate(180deg);
|
||||
@include transform(rotate(180deg));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +133,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background-color: $code-background-color-dark;
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +155,7 @@
|
|||
color: $global-font-secondary-color;
|
||||
}
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
background: $code-background-color-dark;
|
||||
|
||||
rt {
|
||||
|
|
|
@ -30,7 +30,7 @@ $global-link-hover-color: #2d96bd !default;
|
|||
$global-link-hover-color-dark: #fff !default;
|
||||
|
||||
// Color of the border
|
||||
$global-border-color: #dcdcdc !default;
|
||||
$global-border-color: #cacaca !default;
|
||||
$global-border-color-dark: #4a4b50 !default;
|
||||
// ========== Global ========== //
|
||||
|
||||
|
@ -44,14 +44,13 @@ $scrollbar-hover-color: #a9a9b3 !default;
|
|||
|
||||
// ========== Selection ========== //
|
||||
// Color of the selected text
|
||||
$selection-color: rgba(38, 139, 211, 0.2) !default;
|
||||
$selection-color-dark: rgba(38, 139, 211, 0.3) !default;
|
||||
$selection-color: rgba(53, 166, 247, 0.25) !default;
|
||||
$selection-color-dark: rgba(50, 112, 194, 0.4) !default;
|
||||
// ========== Selection ========== //
|
||||
|
||||
// ========== Header ========== //
|
||||
// Height of the header
|
||||
$header-height-desktop: 3.5rem !default;
|
||||
$header-height-mobile: 3.5rem !default;
|
||||
$header-height: 3.5rem !default;
|
||||
|
||||
// Color of the header background
|
||||
$header-background-color: #f8f8f8 !default;
|
||||
|
@ -68,12 +67,16 @@ $header-position-desktop: if($header-normal-mode-desktop, static, fixed) !defaul
|
|||
$header-position-mobile: if($header-normal-mode-mobile, static, fixed) !default;
|
||||
|
||||
// Top of the page padding
|
||||
$page-padding-top-desktop: if($header-normal-mode-desktop, 0, $header-height-desktop) !default;
|
||||
$page-padding-top-mobile: if($header-normal-mode-mobile, 0, $header-height-mobile) !default;
|
||||
$page-padding-top-desktop: if($header-normal-mode-desktop, 0, $header-height) !default;
|
||||
$page-padding-top-mobile: if($header-normal-mode-mobile, 0, $header-height) !default;
|
||||
|
||||
// Color of the hover header item
|
||||
$header-hover-color: #161209 !default;
|
||||
$header-hover-color-dark: #fff !default;
|
||||
|
||||
// Color of the search background
|
||||
$search-background-color: #e9e9e9 !default;
|
||||
$search-background-color-dark: #363636 !default;
|
||||
// ========== Header ========== //
|
||||
|
||||
// ========== Single Content ========== //
|
||||
|
|
3
assets/js/theme.min.js
vendored
3
assets/js/theme.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -2,16 +2,19 @@ fontawesome-free@5.12.1 https://fontawesome.com/
|
|||
forkawesome@1.1.7 https://forkaweso.me/Fork-Awesome/
|
||||
animate.css@3.7.2 https://github.com/daneden/animate.css
|
||||
smooth-scroll@16.1.2 https://github.com/cferdinandi/smooth-scroll
|
||||
autocomplete.js@0.37.1 https://github.com/algolia/autocomplete.js
|
||||
lunr.js@2.3.8 https://lunrjs.com/
|
||||
algoliasearch@4.1.0 https://github.com/algolia/algoliasearch-client-javascript
|
||||
sharer@0.4.0 https://github.com/ellisonleao/sharer.js
|
||||
lazysizes@5.2.0 https://github.com/aFarkas/lazysizes
|
||||
lightgallery@1.1.3 lg-thumbnail@1.1.0 lg-zoom@1.1.0 https://github.com/sachinchoolur/lightgallery.js
|
||||
typeit@6.5.1 https://github.com/alexmacarthur/typeit
|
||||
katex@0.11.1 https://github.com/KaTeX/KaTeX
|
||||
katex@0.11.1 https://katex.org/
|
||||
mermaid@8.4.8 https://github.com/knsv/mermaid
|
||||
aplayer@1.10.1 https://github.com/MoePlayer/APlayer
|
||||
meting@2.0.1 https://github.com/metowolf/MetingJS
|
||||
echarts@4.6.0 https://echarts.apache.org/
|
||||
mapbox-gl@1.8.1 https://github.com/mapbox/mapbox-gl-js
|
||||
aplayer@1.10.1 https://github.com/MoePlayer/APlayer
|
||||
meting@2.0.1 https://github.com/metowolf/MetingJS
|
||||
gitalk@1.6.2 https://github.com/gitalk/gitalk
|
||||
valine@1.3.10 https://valine.js.org/
|
||||
iconfont https://www.iconfont.cn/
|
||||
|
|
2
assets/lib/algoliasearch/algoliasearch-lite.umd.min.js
vendored
Normal file
2
assets/lib/algoliasearch/algoliasearch-lite.umd.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
|||
.dark-theme .aplayer {
|
||||
.dark .aplayer {
|
||||
background: #212121;
|
||||
|
||||
&.aplayer-withlist {
|
||||
|
|
7
assets/lib/autocomplete/autocomplete.min.js
vendored
Normal file
7
assets/lib/autocomplete/autocomplete.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
703
assets/lib/lunr/lunr.fr.js
Normal file
703
assets/lib/lunr/lunr.fr.js
Normal file
|
@ -0,0 +1,703 @@
|
|||
/*!
|
||||
* Lunr languages, `French` language
|
||||
* https://github.com/MihaiValentin/lunr-languages
|
||||
*
|
||||
* Copyright 2014, Mihai Valentin
|
||||
* http://www.mozilla.org/MPL/
|
||||
*/
|
||||
/*!
|
||||
* based on
|
||||
* Snowball JavaScript Library v0.3
|
||||
* http://code.google.com/p/urim/
|
||||
* http://snowball.tartarus.org/
|
||||
*
|
||||
* Copyright 2010, Oleg Mazko
|
||||
* http://www.mozilla.org/MPL/
|
||||
*/
|
||||
|
||||
/**
|
||||
* export the module via AMD, CommonJS or as a browser global
|
||||
* Export code from https://github.com/umdjs/umd/blob/master/returnExports.js
|
||||
*/
|
||||
;
|
||||
(function(root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(factory)
|
||||
} else if (typeof exports === 'object') {
|
||||
/**
|
||||
* Node. Does not work with strict CommonJS, but
|
||||
* only CommonJS-like environments that support module.exports,
|
||||
* like Node.
|
||||
*/
|
||||
module.exports = factory()
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
factory()(root.lunr);
|
||||
}
|
||||
}(this, function() {
|
||||
/**
|
||||
* Just return a value to define the module export.
|
||||
* This example returns an object, but the module
|
||||
* can return a function as the exported value.
|
||||
*/
|
||||
return function(lunr) {
|
||||
/* throw error if lunr is not yet included */
|
||||
if ('undefined' === typeof lunr) {
|
||||
throw new Error('Lunr is not present. Please include / require Lunr before this script.');
|
||||
}
|
||||
|
||||
/* throw error if lunr stemmer support is not yet included */
|
||||
if ('undefined' === typeof lunr.stemmerSupport) {
|
||||
throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.');
|
||||
}
|
||||
|
||||
/* register specific locale function */
|
||||
lunr.fr = function() {
|
||||
this.pipeline.reset();
|
||||
this.pipeline.add(
|
||||
lunr.fr.trimmer,
|
||||
lunr.fr.stopWordFilter,
|
||||
lunr.fr.stemmer
|
||||
);
|
||||
|
||||
// for lunr version 2
|
||||
// this is necessary so that every searched word is also stemmed before
|
||||
// in lunr <= 1 this is not needed, as it is done using the normal pipeline
|
||||
if (this.searchPipeline) {
|
||||
this.searchPipeline.reset();
|
||||
this.searchPipeline.add(lunr.fr.stemmer)
|
||||
}
|
||||
};
|
||||
|
||||
/* lunr trimmer function */
|
||||
lunr.fr.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A";
|
||||
lunr.fr.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.fr.wordCharacters);
|
||||
|
||||
lunr.Pipeline.registerFunction(lunr.fr.trimmer, 'trimmer-fr');
|
||||
|
||||
/* lunr stemmer function */
|
||||
lunr.fr.stemmer = (function() {
|
||||
/* create the wrapped stemmer object */
|
||||
var Among = lunr.stemmerSupport.Among,
|
||||
SnowballProgram = lunr.stemmerSupport.SnowballProgram,
|
||||
st = new function FrenchStemmer() {
|
||||
var a_0 = [new Among("col", -1, -1), new Among("par", -1, -1),
|
||||
new Among("tap", -1, -1)
|
||||
],
|
||||
a_1 = [new Among("", -1, 4),
|
||||
new Among("I", 0, 1), new Among("U", 0, 2), new Among("Y", 0, 3)
|
||||
],
|
||||
a_2 = [
|
||||
new Among("iqU", -1, 3), new Among("abl", -1, 3),
|
||||
new Among("I\u00E8r", -1, 4), new Among("i\u00E8r", -1, 4),
|
||||
new Among("eus", -1, 2), new Among("iv", -1, 1)
|
||||
],
|
||||
a_3 = [
|
||||
new Among("ic", -1, 2), new Among("abil", -1, 1),
|
||||
new Among("iv", -1, 3)
|
||||
],
|
||||
a_4 = [new Among("iqUe", -1, 1),
|
||||
new Among("atrice", -1, 2), new Among("ance", -1, 1),
|
||||
new Among("ence", -1, 5), new Among("logie", -1, 3),
|
||||
new Among("able", -1, 1), new Among("isme", -1, 1),
|
||||
new Among("euse", -1, 11), new Among("iste", -1, 1),
|
||||
new Among("ive", -1, 8), new Among("if", -1, 8),
|
||||
new Among("usion", -1, 4), new Among("ation", -1, 2),
|
||||
new Among("ution", -1, 4), new Among("ateur", -1, 2),
|
||||
new Among("iqUes", -1, 1), new Among("atrices", -1, 2),
|
||||
new Among("ances", -1, 1), new Among("ences", -1, 5),
|
||||
new Among("logies", -1, 3), new Among("ables", -1, 1),
|
||||
new Among("ismes", -1, 1), new Among("euses", -1, 11),
|
||||
new Among("istes", -1, 1), new Among("ives", -1, 8),
|
||||
new Among("ifs", -1, 8), new Among("usions", -1, 4),
|
||||
new Among("ations", -1, 2), new Among("utions", -1, 4),
|
||||
new Among("ateurs", -1, 2), new Among("ments", -1, 15),
|
||||
new Among("ements", 30, 6), new Among("issements", 31, 12),
|
||||
new Among("it\u00E9s", -1, 7), new Among("ment", -1, 15),
|
||||
new Among("ement", 34, 6), new Among("issement", 35, 12),
|
||||
new Among("amment", 34, 13), new Among("emment", 34, 14),
|
||||
new Among("aux", -1, 10), new Among("eaux", 39, 9),
|
||||
new Among("eux", -1, 1), new Among("it\u00E9", -1, 7)
|
||||
],
|
||||
a_5 = [
|
||||
new Among("ira", -1, 1), new Among("ie", -1, 1),
|
||||
new Among("isse", -1, 1), new Among("issante", -1, 1),
|
||||
new Among("i", -1, 1), new Among("irai", 4, 1),
|
||||
new Among("ir", -1, 1), new Among("iras", -1, 1),
|
||||
new Among("ies", -1, 1), new Among("\u00EEmes", -1, 1),
|
||||
new Among("isses", -1, 1), new Among("issantes", -1, 1),
|
||||
new Among("\u00EEtes", -1, 1), new Among("is", -1, 1),
|
||||
new Among("irais", 13, 1), new Among("issais", 13, 1),
|
||||
new Among("irions", -1, 1), new Among("issions", -1, 1),
|
||||
new Among("irons", -1, 1), new Among("issons", -1, 1),
|
||||
new Among("issants", -1, 1), new Among("it", -1, 1),
|
||||
new Among("irait", 21, 1), new Among("issait", 21, 1),
|
||||
new Among("issant", -1, 1), new Among("iraIent", -1, 1),
|
||||
new Among("issaIent", -1, 1), new Among("irent", -1, 1),
|
||||
new Among("issent", -1, 1), new Among("iront", -1, 1),
|
||||
new Among("\u00EEt", -1, 1), new Among("iriez", -1, 1),
|
||||
new Among("issiez", -1, 1), new Among("irez", -1, 1),
|
||||
new Among("issez", -1, 1)
|
||||
],
|
||||
a_6 = [new Among("a", -1, 3),
|
||||
new Among("era", 0, 2), new Among("asse", -1, 3),
|
||||
new Among("ante", -1, 3), new Among("\u00E9e", -1, 2),
|
||||
new Among("ai", -1, 3), new Among("erai", 5, 2),
|
||||
new Among("er", -1, 2), new Among("as", -1, 3),
|
||||
new Among("eras", 8, 2), new Among("\u00E2mes", -1, 3),
|
||||
new Among("asses", -1, 3), new Among("antes", -1, 3),
|
||||
new Among("\u00E2tes", -1, 3), new Among("\u00E9es", -1, 2),
|
||||
new Among("ais", -1, 3), new Among("erais", 15, 2),
|
||||
new Among("ions", -1, 1), new Among("erions", 17, 2),
|
||||
new Among("assions", 17, 3), new Among("erons", -1, 2),
|
||||
new Among("ants", -1, 3), new Among("\u00E9s", -1, 2),
|
||||
new Among("ait", -1, 3), new Among("erait", 23, 2),
|
||||
new Among("ant", -1, 3), new Among("aIent", -1, 3),
|
||||
new Among("eraIent", 26, 2), new Among("\u00E8rent", -1, 2),
|
||||
new Among("assent", -1, 3), new Among("eront", -1, 2),
|
||||
new Among("\u00E2t", -1, 3), new Among("ez", -1, 2),
|
||||
new Among("iez", 32, 2), new Among("eriez", 33, 2),
|
||||
new Among("assiez", 33, 3), new Among("erez", 32, 2),
|
||||
new Among("\u00E9", -1, 2)
|
||||
],
|
||||
a_7 = [new Among("e", -1, 3),
|
||||
new Among("I\u00E8re", 0, 2), new Among("i\u00E8re", 0, 2),
|
||||
new Among("ion", -1, 1), new Among("Ier", -1, 2),
|
||||
new Among("ier", -1, 2), new Among("\u00EB", -1, 4)
|
||||
],
|
||||
a_8 = [
|
||||
new Among("ell", -1, -1), new Among("eill", -1, -1),
|
||||
new Among("enn", -1, -1), new Among("onn", -1, -1),
|
||||
new Among("ett", -1, -1)
|
||||
],
|
||||
g_v = [17, 65, 16, 1, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 128, 130, 103, 8, 5
|
||||
],
|
||||
g_keep_with_s = [1, 65, 20, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128
|
||||
],
|
||||
I_p2, I_p1, I_pV, sbp = new SnowballProgram();
|
||||
this.setCurrent = function(word) {
|
||||
sbp.setCurrent(word);
|
||||
};
|
||||
this.getCurrent = function() {
|
||||
return sbp.getCurrent();
|
||||
};
|
||||
|
||||
function habr1(c1, c2, v_1) {
|
||||
if (sbp.eq_s(1, c1)) {
|
||||
sbp.ket = sbp.cursor;
|
||||
if (sbp.in_grouping(g_v, 97, 251)) {
|
||||
sbp.slice_from(c2);
|
||||
sbp.cursor = v_1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function habr2(c1, c2, v_1) {
|
||||
if (sbp.eq_s(1, c1)) {
|
||||
sbp.ket = sbp.cursor;
|
||||
sbp.slice_from(c2);
|
||||
sbp.cursor = v_1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function r_prelude() {
|
||||
var v_1, v_2;
|
||||
while (true) {
|
||||
v_1 = sbp.cursor;
|
||||
if (sbp.in_grouping(g_v, 97, 251)) {
|
||||
sbp.bra = sbp.cursor;
|
||||
v_2 = sbp.cursor;
|
||||
if (habr1("u", "U", v_1))
|
||||
continue;
|
||||
sbp.cursor = v_2;
|
||||
if (habr1("i", "I", v_1))
|
||||
continue;
|
||||
sbp.cursor = v_2;
|
||||
if (habr2("y", "Y", v_1))
|
||||
continue;
|
||||
}
|
||||
sbp.cursor = v_1;
|
||||
sbp.bra = v_1;
|
||||
if (!habr1("y", "Y", v_1)) {
|
||||
sbp.cursor = v_1;
|
||||
if (sbp.eq_s(1, "q")) {
|
||||
sbp.bra = sbp.cursor;
|
||||
if (habr2("u", "U", v_1))
|
||||
continue;
|
||||
}
|
||||
sbp.cursor = v_1;
|
||||
if (v_1 >= sbp.limit)
|
||||
return;
|
||||
sbp.cursor++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function habr3() {
|
||||
while (!sbp.in_grouping(g_v, 97, 251)) {
|
||||
if (sbp.cursor >= sbp.limit)
|
||||
return true;
|
||||
sbp.cursor++;
|
||||
}
|
||||
while (!sbp.out_grouping(g_v, 97, 251)) {
|
||||
if (sbp.cursor >= sbp.limit)
|
||||
return true;
|
||||
sbp.cursor++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function r_mark_regions() {
|
||||
var v_1 = sbp.cursor;
|
||||
I_pV = sbp.limit;
|
||||
I_p1 = I_pV;
|
||||
I_p2 = I_pV;
|
||||
if (sbp.in_grouping(g_v, 97, 251) && sbp.in_grouping(g_v, 97, 251) &&
|
||||
sbp.cursor < sbp.limit)
|
||||
sbp.cursor++;
|
||||
else {
|
||||
sbp.cursor = v_1;
|
||||
if (!sbp.find_among(a_0, 3)) {
|
||||
sbp.cursor = v_1;
|
||||
do {
|
||||
if (sbp.cursor >= sbp.limit) {
|
||||
sbp.cursor = I_pV;
|
||||
break;
|
||||
}
|
||||
sbp.cursor++;
|
||||
} while (!sbp.in_grouping(g_v, 97, 251));
|
||||
}
|
||||
}
|
||||
I_pV = sbp.cursor;
|
||||
sbp.cursor = v_1;
|
||||
if (!habr3()) {
|
||||
I_p1 = sbp.cursor;
|
||||
if (!habr3())
|
||||
I_p2 = sbp.cursor;
|
||||
}
|
||||
}
|
||||
|
||||
function r_postlude() {
|
||||
var among_var, v_1;
|
||||
while (true) {
|
||||
v_1 = sbp.cursor;
|
||||
sbp.bra = v_1;
|
||||
among_var = sbp.find_among(a_1, 4);
|
||||
if (!among_var)
|
||||
break;
|
||||
sbp.ket = sbp.cursor;
|
||||
switch (among_var) {
|
||||
case 1:
|
||||
sbp.slice_from("i");
|
||||
break;
|
||||
case 2:
|
||||
sbp.slice_from("u");
|
||||
break;
|
||||
case 3:
|
||||
sbp.slice_from("y");
|
||||
break;
|
||||
case 4:
|
||||
if (sbp.cursor >= sbp.limit)
|
||||
return;
|
||||
sbp.cursor++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function r_RV() {
|
||||
return I_pV <= sbp.cursor;
|
||||
}
|
||||
|
||||
function r_R1() {
|
||||
return I_p1 <= sbp.cursor;
|
||||
}
|
||||
|
||||
function r_R2() {
|
||||
return I_p2 <= sbp.cursor;
|
||||
}
|
||||
|
||||
function r_standard_suffix() {
|
||||
var among_var, v_1;
|
||||
sbp.ket = sbp.cursor;
|
||||
among_var = sbp.find_among_b(a_4, 43);
|
||||
if (among_var) {
|
||||
sbp.bra = sbp.cursor;
|
||||
switch (among_var) {
|
||||
case 1:
|
||||
if (!r_R2())
|
||||
return false;
|
||||
sbp.slice_del();
|
||||
break;
|
||||
case 2:
|
||||
if (!r_R2())
|
||||
return false;
|
||||
sbp.slice_del();
|
||||
sbp.ket = sbp.cursor;
|
||||
if (sbp.eq_s_b(2, "ic")) {
|
||||
sbp.bra = sbp.cursor;
|
||||
if (!r_R2())
|
||||
sbp.slice_from("iqU");
|
||||
else
|
||||
sbp.slice_del();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (!r_R2())
|
||||
return false;
|
||||
sbp.slice_from("log");
|
||||
break;
|
||||
case 4:
|
||||
if (!r_R2())
|
||||
return false;
|
||||
sbp.slice_from("u");
|
||||
break;
|
||||
case 5:
|
||||
if (!r_R2())
|
||||
return false;
|
||||
sbp.slice_from("ent");
|
||||
break;
|
||||
case 6:
|
||||
if (!r_RV())
|
||||
return false;
|
||||
sbp.slice_del();
|
||||
sbp.ket = sbp.cursor;
|
||||
among_var = sbp.find_among_b(a_2, 6);
|
||||
if (among_var) {
|
||||
sbp.bra = sbp.cursor;
|
||||
switch (among_var) {
|
||||
case 1:
|
||||
if (r_R2()) {
|
||||
sbp.slice_del();
|
||||
sbp.ket = sbp.cursor;
|
||||
if (sbp.eq_s_b(2, "at")) {
|
||||
sbp.bra = sbp.cursor;
|
||||
if (r_R2())
|
||||
sbp.slice_del();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (r_R2())
|
||||
sbp.slice_del();
|
||||
else if (r_R1())
|
||||
sbp.slice_from("eux");
|
||||
break;
|
||||
case 3:
|
||||
if (r_R2())
|
||||
sbp.slice_del();
|
||||
break;
|
||||
case 4:
|
||||
if (r_RV())
|
||||
sbp.slice_from("i");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (!r_R2())
|
||||
return false;
|
||||
sbp.slice_del();
|
||||
sbp.ket = sbp.cursor;
|
||||
among_var = sbp.find_among_b(a_3, 3);
|
||||
if (among_var) {
|
||||
sbp.bra = sbp.cursor;
|
||||
switch (among_var) {
|
||||
case 1:
|
||||
if (r_R2())
|
||||
sbp.slice_del();
|
||||
else
|
||||
sbp.slice_from("abl");
|
||||
break;
|
||||
case 2:
|
||||
if (r_R2())
|
||||
sbp.slice_del();
|
||||
else
|
||||
sbp.slice_from("iqU");
|
||||
break;
|
||||
case 3:
|
||||
if (r_R2())
|
||||
sbp.slice_del();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if (!r_R2())
|
||||
return false;
|
||||
sbp.slice_del();
|
||||
sbp.ket = sbp.cursor;
|
||||
if (sbp.eq_s_b(2, "at")) {
|
||||
sbp.bra = sbp.cursor;
|
||||
if (r_R2()) {
|
||||
sbp.slice_del();
|
||||
sbp.ket = sbp.cursor;
|
||||
if (sbp.eq_s_b(2, "ic")) {
|
||||
sbp.bra = sbp.cursor;
|
||||
if (r_R2())
|
||||
sbp.slice_del();
|
||||
else
|
||||
sbp.slice_from("iqU");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
sbp.slice_from("eau");
|
||||
break;
|
||||
case 10:
|
||||
if (!r_R1())
|
||||
return false;
|
||||
sbp.slice_from("al");
|
||||
break;
|
||||
case 11:
|
||||
if (r_R2())
|
||||
sbp.slice_del();
|
||||
else if (!r_R1())
|
||||
return false;
|
||||
else
|
||||
sbp.slice_from("eux");
|
||||
break;
|
||||
case 12:
|
||||
if (!r_R1() || !sbp.out_grouping_b(g_v, 97, 251))
|
||||
return false;
|
||||
sbp.slice_del();
|
||||
break;
|
||||
case 13:
|
||||
if (r_RV())
|
||||
sbp.slice_from("ant");
|
||||
return false;
|
||||
case 14:
|
||||
if (r_RV())
|
||||
sbp.slice_from("ent");
|
||||
return false;
|
||||
case 15:
|
||||
v_1 = sbp.limit - sbp.cursor;
|
||||
if (sbp.in_grouping_b(g_v, 97, 251) && r_RV()) {
|
||||
sbp.cursor = sbp.limit - v_1;
|
||||
sbp.slice_del();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function r_i_verb_suffix() {
|
||||
var among_var, v_1;
|
||||
if (sbp.cursor < I_pV)
|
||||
return false;
|
||||
v_1 = sbp.limit_backward;
|
||||
sbp.limit_backward = I_pV;
|
||||
sbp.ket = sbp.cursor;
|
||||
among_var = sbp.find_among_b(a_5, 35);
|
||||
if (!among_var) {
|
||||
sbp.limit_backward = v_1;
|
||||
return false;
|
||||
}
|
||||
sbp.bra = sbp.cursor;
|
||||
if (among_var == 1) {
|
||||
if (!sbp.out_grouping_b(g_v, 97, 251)) {
|
||||
sbp.limit_backward = v_1;
|
||||
return false;
|
||||
}
|
||||
sbp.slice_del();
|
||||
}
|
||||
sbp.limit_backward = v_1;
|
||||
return true;
|
||||
}
|
||||
|
||||
function r_verb_suffix() {
|
||||
var among_var, v_2, v_3;
|
||||
if (sbp.cursor < I_pV)
|
||||
return false;
|
||||
v_2 = sbp.limit_backward;
|
||||
sbp.limit_backward = I_pV;
|
||||
sbp.ket = sbp.cursor;
|
||||
among_var = sbp.find_among_b(a_6, 38);
|
||||
if (!among_var) {
|
||||
sbp.limit_backward = v_2;
|
||||
return false;
|
||||
}
|
||||
sbp.bra = sbp.cursor;
|
||||
switch (among_var) {
|
||||
case 1:
|
||||
if (!r_R2()) {
|
||||
sbp.limit_backward = v_2;
|
||||
return false;
|
||||
}
|
||||
sbp.slice_del();
|
||||
break;
|
||||
case 2:
|
||||
sbp.slice_del();
|
||||
break;
|
||||
case 3:
|
||||
sbp.slice_del();
|
||||
v_3 = sbp.limit - sbp.cursor;
|
||||
sbp.ket = sbp.cursor;
|
||||
if (sbp.eq_s_b(1, "e")) {
|
||||
sbp.bra = sbp.cursor;
|
||||
sbp.slice_del();
|
||||
} else
|
||||
sbp.cursor = sbp.limit - v_3;
|
||||
break;
|
||||
}
|
||||
sbp.limit_backward = v_2;
|
||||
return true;
|
||||
}
|
||||
|
||||
function r_residual_suffix() {
|
||||
var among_var, v_1 = sbp.limit - sbp.cursor,
|
||||
v_2, v_4, v_5;
|
||||
sbp.ket = sbp.cursor;
|
||||
if (sbp.eq_s_b(1, "s")) {
|
||||
sbp.bra = sbp.cursor;
|
||||
v_2 = sbp.limit - sbp.cursor;
|
||||
if (sbp.out_grouping_b(g_keep_with_s, 97, 232)) {
|
||||
sbp.cursor = sbp.limit - v_2;
|
||||
sbp.slice_del();
|
||||
} else
|
||||
sbp.cursor = sbp.limit - v_1;
|
||||
} else
|
||||
sbp.cursor = sbp.limit - v_1;
|
||||
if (sbp.cursor >= I_pV) {
|
||||
v_4 = sbp.limit_backward;
|
||||
sbp.limit_backward = I_pV;
|
||||
sbp.ket = sbp.cursor;
|
||||
among_var = sbp.find_among_b(a_7, 7);
|
||||
if (among_var) {
|
||||
sbp.bra = sbp.cursor;
|
||||
switch (among_var) {
|
||||
case 1:
|
||||
if (r_R2()) {
|
||||
v_5 = sbp.limit - sbp.cursor;
|
||||
if (!sbp.eq_s_b(1, "s")) {
|
||||
sbp.cursor = sbp.limit - v_5;
|
||||
if (!sbp.eq_s_b(1, "t"))
|
||||
break;
|
||||
}
|
||||
sbp.slice_del();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
sbp.slice_from("i");
|
||||
break;
|
||||
case 3:
|
||||
sbp.slice_del();
|
||||
break;
|
||||
case 4:
|
||||
if (sbp.eq_s_b(2, "gu"))
|
||||
sbp.slice_del();
|
||||
break;
|
||||
}
|
||||
}
|
||||
sbp.limit_backward = v_4;
|
||||
}
|
||||
}
|
||||
|
||||
function r_un_double() {
|
||||
var v_1 = sbp.limit - sbp.cursor;
|
||||
if (sbp.find_among_b(a_8, 5)) {
|
||||
sbp.cursor = sbp.limit - v_1;
|
||||
sbp.ket = sbp.cursor;
|
||||
if (sbp.cursor > sbp.limit_backward) {
|
||||
sbp.cursor--;
|
||||
sbp.bra = sbp.cursor;
|
||||
sbp.slice_del();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function r_un_accent() {
|
||||
var v_1, v_2 = 1;
|
||||
while (sbp.out_grouping_b(g_v, 97, 251))
|
||||
v_2--;
|
||||
if (v_2 <= 0) {
|
||||
sbp.ket = sbp.cursor;
|
||||
v_1 = sbp.limit - sbp.cursor;
|
||||
if (!sbp.eq_s_b(1, "\u00E9")) {
|
||||
sbp.cursor = sbp.limit - v_1;
|
||||
if (!sbp.eq_s_b(1, "\u00E8"))
|
||||
return;
|
||||
}
|
||||
sbp.bra = sbp.cursor;
|
||||
sbp.slice_from("e");
|
||||
}
|
||||
}
|
||||
|
||||
function habr5() {
|
||||
if (!r_standard_suffix()) {
|
||||
sbp.cursor = sbp.limit;
|
||||
if (!r_i_verb_suffix()) {
|
||||
sbp.cursor = sbp.limit;
|
||||
if (!r_verb_suffix()) {
|
||||
sbp.cursor = sbp.limit;
|
||||
r_residual_suffix();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
sbp.cursor = sbp.limit;
|
||||
sbp.ket = sbp.cursor;
|
||||
if (sbp.eq_s_b(1, "Y")) {
|
||||
sbp.bra = sbp.cursor;
|
||||
sbp.slice_from("i");
|
||||
} else {
|
||||
sbp.cursor = sbp.limit;
|
||||
if (sbp.eq_s_b(1, "\u00E7")) {
|
||||
sbp.bra = sbp.cursor;
|
||||
sbp.slice_from("c");
|
||||
}
|
||||
}
|
||||
}
|
||||
this.stem = function() {
|
||||
var v_1 = sbp.cursor;
|
||||
r_prelude();
|
||||
sbp.cursor = v_1;
|
||||
r_mark_regions();
|
||||
sbp.limit_backward = v_1;
|
||||
sbp.cursor = sbp.limit;
|
||||
habr5();
|
||||
sbp.cursor = sbp.limit;
|
||||
r_un_double();
|
||||
sbp.cursor = sbp.limit;
|
||||
r_un_accent();
|
||||
sbp.cursor = sbp.limit_backward;
|
||||
r_postlude();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/* and return a function that stems a word for the current locale */
|
||||
return function(token) {
|
||||
// for lunr version 2
|
||||
if (typeof token.update === "function") {
|
||||
return token.update(function(word) {
|
||||
st.setCurrent(word);
|
||||
st.stem();
|
||||
return st.getCurrent();
|
||||
})
|
||||
} else { // for lunr version <= 1
|
||||
st.setCurrent(token);
|
||||
st.stem();
|
||||
return st.getCurrent();
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
lunr.Pipeline.registerFunction(lunr.fr.stemmer, 'stemmer-fr');
|
||||
|
||||
lunr.fr.stopWordFilter = lunr.generateStopWordFilter('ai aie aient aies ait as au aura aurai auraient aurais aurait auras aurez auriez aurions aurons auront aux avaient avais avait avec avez aviez avions avons ayant ayez ayons c ce ceci celà ces cet cette d dans de des du elle en es est et eu eue eues eurent eus eusse eussent eusses eussiez eussions eut eux eûmes eût eûtes furent fus fusse fussent fusses fussiez fussions fut fûmes fût fûtes ici il ils j je l la le les leur leurs lui m ma mais me mes moi mon même n ne nos notre nous on ont ou par pas pour qu que quel quelle quelles quels qui s sa sans se sera serai seraient serais serait seras serez seriez serions serons seront ses soi soient sois soit sommes son sont soyez soyons suis sur t ta te tes toi ton tu un une vos votre vous y à étaient étais était étant étiez étions été étée étées étés êtes'.split(' '));
|
||||
|
||||
lunr.Pipeline.registerFunction(lunr.fr.stopWordFilter, 'stopWordFilter-fr');
|
||||
};
|
||||
}))
|
6
assets/lib/lunr/lunr.min.js
vendored
Normal file
6
assets/lib/lunr/lunr.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
174
assets/lib/lunr/lunr.segmentit.js
Normal file
174
assets/lib/lunr/lunr.segmentit.js
Normal file
File diff suppressed because one or more lines are too long
304
assets/lib/lunr/lunr.stemmer.support.js
Normal file
304
assets/lib/lunr/lunr.stemmer.support.js
Normal file
|
@ -0,0 +1,304 @@
|
|||
/*!
|
||||
* Snowball JavaScript Library v0.3
|
||||
* http://code.google.com/p/urim/
|
||||
* http://snowball.tartarus.org/
|
||||
*
|
||||
* Copyright 2010, Oleg Mazko
|
||||
* http://www.mozilla.org/MPL/
|
||||
*/
|
||||
|
||||
/**
|
||||
* export the module via AMD, CommonJS or as a browser global
|
||||
* Export code from https://github.com/umdjs/umd/blob/master/returnExports.js
|
||||
*/
|
||||
;(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(factory)
|
||||
} else if (typeof exports === 'object') {
|
||||
/**
|
||||
* Node. Does not work with strict CommonJS, but
|
||||
* only CommonJS-like environments that support module.exports,
|
||||
* like Node.
|
||||
*/
|
||||
module.exports = factory()
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
factory()(root.lunr);
|
||||
}
|
||||
}(this, function () {
|
||||
/**
|
||||
* Just return a value to define the module export.
|
||||
* This example returns an object, but the module
|
||||
* can return a function as the exported value.
|
||||
*/
|
||||
return function(lunr) {
|
||||
/* provides utilities for the included stemmers */
|
||||
lunr.stemmerSupport = {
|
||||
Among: function(s, substring_i, result, method) {
|
||||
this.toCharArray = function(s) {
|
||||
var sLength = s.length, charArr = new Array(sLength);
|
||||
for (var i = 0; i < sLength; i++)
|
||||
charArr[i] = s.charCodeAt(i);
|
||||
return charArr;
|
||||
};
|
||||
|
||||
if ((!s && s != "") || (!substring_i && (substring_i != 0)) || !result)
|
||||
throw ("Bad Among initialisation: s:" + s + ", substring_i: "
|
||||
+ substring_i + ", result: " + result);
|
||||
this.s_size = s.length;
|
||||
this.s = this.toCharArray(s);
|
||||
this.substring_i = substring_i;
|
||||
this.result = result;
|
||||
this.method = method;
|
||||
},
|
||||
SnowballProgram: function() {
|
||||
var current;
|
||||
return {
|
||||
bra : 0,
|
||||
ket : 0,
|
||||
limit : 0,
|
||||
cursor : 0,
|
||||
limit_backward : 0,
|
||||
setCurrent : function(word) {
|
||||
current = word;
|
||||
this.cursor = 0;
|
||||
this.limit = word.length;
|
||||
this.limit_backward = 0;
|
||||
this.bra = this.cursor;
|
||||
this.ket = this.limit;
|
||||
},
|
||||
getCurrent : function() {
|
||||
var result = current;
|
||||
current = null;
|
||||
return result;
|
||||
},
|
||||
in_grouping : function(s, min, max) {
|
||||
if (this.cursor < this.limit) {
|
||||
var ch = current.charCodeAt(this.cursor);
|
||||
if (ch <= max && ch >= min) {
|
||||
ch -= min;
|
||||
if (s[ch >> 3] & (0X1 << (ch & 0X7))) {
|
||||
this.cursor++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
in_grouping_b : function(s, min, max) {
|
||||
if (this.cursor > this.limit_backward) {
|
||||
var ch = current.charCodeAt(this.cursor - 1);
|
||||
if (ch <= max && ch >= min) {
|
||||
ch -= min;
|
||||
if (s[ch >> 3] & (0X1 << (ch & 0X7))) {
|
||||
this.cursor--;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
out_grouping : function(s, min, max) {
|
||||
if (this.cursor < this.limit) {
|
||||
var ch = current.charCodeAt(this.cursor);
|
||||
if (ch > max || ch < min) {
|
||||
this.cursor++;
|
||||
return true;
|
||||
}
|
||||
ch -= min;
|
||||
if (!(s[ch >> 3] & (0X1 << (ch & 0X7)))) {
|
||||
this.cursor++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
out_grouping_b : function(s, min, max) {
|
||||
if (this.cursor > this.limit_backward) {
|
||||
var ch = current.charCodeAt(this.cursor - 1);
|
||||
if (ch > max || ch < min) {
|
||||
this.cursor--;
|
||||
return true;
|
||||
}
|
||||
ch -= min;
|
||||
if (!(s[ch >> 3] & (0X1 << (ch & 0X7)))) {
|
||||
this.cursor--;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
eq_s : function(s_size, s) {
|
||||
if (this.limit - this.cursor < s_size)
|
||||
return false;
|
||||
for (var i = 0; i < s_size; i++)
|
||||
if (current.charCodeAt(this.cursor + i) != s.charCodeAt(i))
|
||||
return false;
|
||||
this.cursor += s_size;
|
||||
return true;
|
||||
},
|
||||
eq_s_b : function(s_size, s) {
|
||||
if (this.cursor - this.limit_backward < s_size)
|
||||
return false;
|
||||
for (var i = 0; i < s_size; i++)
|
||||
if (current.charCodeAt(this.cursor - s_size + i) != s
|
||||
.charCodeAt(i))
|
||||
return false;
|
||||
this.cursor -= s_size;
|
||||
return true;
|
||||
},
|
||||
find_among : function(v, v_size) {
|
||||
var i = 0, j = v_size, c = this.cursor, l = this.limit, common_i = 0, common_j = 0, first_key_inspected = false;
|
||||
while (true) {
|
||||
var k = i + ((j - i) >> 1), diff = 0, common = common_i < common_j
|
||||
? common_i
|
||||
: common_j, w = v[k];
|
||||
for (var i2 = common; i2 < w.s_size; i2++) {
|
||||
if (c + common == l) {
|
||||
diff = -1;
|
||||
break;
|
||||
}
|
||||
diff = current.charCodeAt(c + common) - w.s[i2];
|
||||
if (diff)
|
||||
break;
|
||||
common++;
|
||||
}
|
||||
if (diff < 0) {
|
||||
j = k;
|
||||
common_j = common;
|
||||
} else {
|
||||
i = k;
|
||||
common_i = common;
|
||||
}
|
||||
if (j - i <= 1) {
|
||||
if (i > 0 || j == i || first_key_inspected)
|
||||
break;
|
||||
first_key_inspected = true;
|
||||
}
|
||||
}
|
||||
while (true) {
|
||||
var w = v[i];
|
||||
if (common_i >= w.s_size) {
|
||||
this.cursor = c + w.s_size;
|
||||
if (!w.method)
|
||||
return w.result;
|
||||
var res = w.method();
|
||||
this.cursor = c + w.s_size;
|
||||
if (res)
|
||||
return w.result;
|
||||
}
|
||||
i = w.substring_i;
|
||||
if (i < 0)
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
find_among_b : function(v, v_size) {
|
||||
var i = 0, j = v_size, c = this.cursor, lb = this.limit_backward, common_i = 0, common_j = 0, first_key_inspected = false;
|
||||
while (true) {
|
||||
var k = i + ((j - i) >> 1), diff = 0, common = common_i < common_j
|
||||
? common_i
|
||||
: common_j, w = v[k];
|
||||
for (var i2 = w.s_size - 1 - common; i2 >= 0; i2--) {
|
||||
if (c - common == lb) {
|
||||
diff = -1;
|
||||
break;
|
||||
}
|
||||
diff = current.charCodeAt(c - 1 - common) - w.s[i2];
|
||||
if (diff)
|
||||
break;
|
||||
common++;
|
||||
}
|
||||
if (diff < 0) {
|
||||
j = k;
|
||||
common_j = common;
|
||||
} else {
|
||||
i = k;
|
||||
common_i = common;
|
||||
}
|
||||
if (j - i <= 1) {
|
||||
if (i > 0 || j == i || first_key_inspected)
|
||||
break;
|
||||
first_key_inspected = true;
|
||||
}
|
||||
}
|
||||
while (true) {
|
||||
var w = v[i];
|
||||
if (common_i >= w.s_size) {
|
||||
this.cursor = c - w.s_size;
|
||||
if (!w.method)
|
||||
return w.result;
|
||||
var res = w.method();
|
||||
this.cursor = c - w.s_size;
|
||||
if (res)
|
||||
return w.result;
|
||||
}
|
||||
i = w.substring_i;
|
||||
if (i < 0)
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
replace_s : function(c_bra, c_ket, s) {
|
||||
var adjustment = s.length - (c_ket - c_bra), left = current
|
||||
.substring(0, c_bra), right = current.substring(c_ket);
|
||||
current = left + s + right;
|
||||
this.limit += adjustment;
|
||||
if (this.cursor >= c_ket)
|
||||
this.cursor += adjustment;
|
||||
else if (this.cursor > c_bra)
|
||||
this.cursor = c_bra;
|
||||
return adjustment;
|
||||
},
|
||||
slice_check : function() {
|
||||
if (this.bra < 0 || this.bra > this.ket || this.ket > this.limit
|
||||
|| this.limit > current.length)
|
||||
throw ("faulty slice operation");
|
||||
},
|
||||
slice_from : function(s) {
|
||||
this.slice_check();
|
||||
this.replace_s(this.bra, this.ket, s);
|
||||
},
|
||||
slice_del : function() {
|
||||
this.slice_from("");
|
||||
},
|
||||
insert : function(c_bra, c_ket, s) {
|
||||
var adjustment = this.replace_s(c_bra, c_ket, s);
|
||||
if (c_bra <= this.bra)
|
||||
this.bra += adjustment;
|
||||
if (c_bra <= this.ket)
|
||||
this.ket += adjustment;
|
||||
},
|
||||
slice_to : function() {
|
||||
this.slice_check();
|
||||
return current.substring(this.bra, this.ket);
|
||||
},
|
||||
eq_v_b : function(s) {
|
||||
return this.eq_s_b(s.length, s);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
lunr.trimmerSupport = {
|
||||
generateTrimmer: function(wordCharacters) {
|
||||
var startRegex = new RegExp("^[^" + wordCharacters + "]+")
|
||||
var endRegex = new RegExp("[^" + wordCharacters + "]+$")
|
||||
|
||||
return function(token) {
|
||||
// for lunr version 2
|
||||
if (typeof token.update === "function") {
|
||||
return token.update(function (s) {
|
||||
return s
|
||||
.replace(startRegex, '')
|
||||
.replace(endRegex, '');
|
||||
})
|
||||
} else { // for lunr version 1
|
||||
return token
|
||||
.replace(startRegex, '')
|
||||
.replace(endRegex, '');
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
141
assets/lib/lunr/lunr.zh.js
Normal file
141
assets/lib/lunr/lunr.zh.js
Normal file
|
@ -0,0 +1,141 @@
|
|||
/*!
|
||||
* Lunr languages, `Chinese` language
|
||||
* https://github.com/MihaiValentin/lunr-languages
|
||||
*
|
||||
* Copyright 2019, Felix Lian (repairearth)
|
||||
* http://www.mozilla.org/MPL/
|
||||
*/
|
||||
/*!
|
||||
* based on
|
||||
* Snowball zhvaScript Library v0.3
|
||||
* http://code.google.com/p/urim/
|
||||
* http://snowball.tartarus.org/
|
||||
*
|
||||
* Copyright 2010, Oleg Mazko
|
||||
* http://www.mozilla.org/MPL/
|
||||
*/
|
||||
|
||||
/**
|
||||
* export the module via AMD, CommonJS or as a browser global
|
||||
* Export code from https://github.com/umdjs/umd/blob/master/returnExports.js
|
||||
*/
|
||||
;
|
||||
(function(root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(factory)
|
||||
} else if (typeof exports === 'object') {
|
||||
/**
|
||||
* Node. Does not work with strict CommonJS, but
|
||||
* only CommonJS-like environments that support module.exports,
|
||||
* like Node.
|
||||
*/
|
||||
module.exports = factory()
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
factory()(root.lunr);
|
||||
}
|
||||
}(this, function() {
|
||||
/**
|
||||
* Just return a value to define the module export.
|
||||
* This example returns an object, but the module
|
||||
* can return a function as the exported value.
|
||||
*/
|
||||
return function(lunr) {
|
||||
/* throw error if lunr is not yet included */
|
||||
if ('undefined' === typeof lunr) {
|
||||
throw new Error('Lunr is not present. Please include / require Lunr before this script.');
|
||||
}
|
||||
|
||||
/* throw error if lunr stemmer support is not yet included */
|
||||
if ('undefined' === typeof lunr.stemmerSupport) {
|
||||
throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.');
|
||||
}
|
||||
|
||||
/*
|
||||
Chinese tokenization is trickier, since it does not
|
||||
take into account spaces.
|
||||
Since the tokenization function is represented different
|
||||
internally for each of the Lunr versions, this had to be done
|
||||
in order to try to try to pick the best way of doing this based
|
||||
on the Lunr version
|
||||
*/
|
||||
var isLunr2 = lunr.version[0] == "2";
|
||||
|
||||
/* register specific locale function */
|
||||
lunr.zh = function() {
|
||||
this.pipeline.reset();
|
||||
this.pipeline.add(
|
||||
lunr.zh.trimmer,
|
||||
lunr.zh.stopWordFilter,
|
||||
lunr.zh.stemmer
|
||||
);
|
||||
|
||||
// change the tokenizer for Chinese one
|
||||
if (isLunr2) { // for lunr version 2.0.0
|
||||
this.tokenizer = lunr.zh.tokenizer;
|
||||
} else {
|
||||
if (lunr.tokenizer) { // for lunr version 0.6.0
|
||||
lunr.tokenizer = lunr.zh.tokenizer;
|
||||
}
|
||||
if (this.tokenizerFn) { // for lunr version 0.7.0 -> 1.0.0
|
||||
this.tokenizerFn = lunr.zh.tokenizer;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
lunr.zh.tokenizer = function(obj) {
|
||||
if (!arguments.length || obj == null || obj == undefined) return []
|
||||
if (Array.isArray(obj)) return obj.map(function (t) { return isLunr2 ? new lunr.Token(t.toLowerCase()) : t.toLowerCase() })
|
||||
|
||||
var str = obj.toString().trim().toLowerCase();
|
||||
var tokens = [];
|
||||
|
||||
lunr.segmentit && lunr.segmentit.doSegment(str).forEach(function (seg) {
|
||||
tokens = tokens.concat(seg.w.split(' '));
|
||||
});
|
||||
|
||||
tokens = tokens.filter(function (token) {
|
||||
return !!token;
|
||||
});
|
||||
|
||||
var fromIndex = 0
|
||||
|
||||
return tokens.map(function (token, index) {
|
||||
if (isLunr2) {
|
||||
var start = str.indexOf(token, fromIndex)
|
||||
|
||||
var tokenMetadata = {}
|
||||
tokenMetadata["position"] = [start, token.length]
|
||||
tokenMetadata["index"] = index
|
||||
|
||||
fromIndex = start
|
||||
|
||||
return new lunr.Token(token, tokenMetadata);
|
||||
} else {
|
||||
return token
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* lunr trimmer function */
|
||||
lunr.zh.wordCharacters = "\\w\u4e00-\u9fa5";
|
||||
lunr.zh.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.zh.wordCharacters);
|
||||
lunr.Pipeline.registerFunction(lunr.zh.trimmer, 'trimmer-zh');
|
||||
|
||||
/* lunr stemmer function */
|
||||
lunr.zh.stemmer = (function() {
|
||||
|
||||
/* TODO Chinese stemmer */
|
||||
return function(word) {
|
||||
return word;
|
||||
}
|
||||
})();
|
||||
lunr.Pipeline.registerFunction(lunr.zh.stemmer, 'stemmer-zh');
|
||||
|
||||
/* lunr stop word filter. see https://www.ranks.nl/stopwords/chinese-stopwords */
|
||||
lunr.zh.stopWordFilter = lunr.generateStopWordFilter(
|
||||
'的 一 不 在 人 有 是 为 以 于 上 他 而 后 之 来 及 了 因 下 可 到 由 这 与 也 此 但 并 个 其 已 无 小 我 们 起 最 再 今 去 好 只 又 或 很 亦 某 把 那 你 乃 它 吧 被 比 别 趁 当 从 到 得 打 凡 儿 尔 该 各 给 跟 和 何 还 即 几 既 看 据 距 靠 啦 了 另 么 每 们 嘛 拿 哪 那 您 凭 且 却 让 仍 啥 如 若 使 谁 虽 随 同 所 她 哇 嗡 往 哪 些 向 沿 哟 用 于 咱 则 怎 曾 至 致 着 诸 自'.split(' '));
|
||||
lunr.Pipeline.registerFunction(lunr.zh.stopWordFilter, 'stopWordFilter-zh');
|
||||
};
|
||||
}))
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
@import "themes/neutral/index";
|
||||
|
||||
.dark-theme & {
|
||||
.dark & {
|
||||
@import "themes/dark/index";
|
||||
}
|
||||
}
|
||||
|
|
8
assets/lib/polyfill.yml
Normal file
8
assets/lib/polyfill.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
smooth-scroll:
|
||||
- Element.prototype.closest
|
||||
- requestAnimationFrame
|
||||
- CustomEvent
|
||||
algoliasearch:
|
||||
- Promise
|
||||
- Object.entries
|
||||
- Object.assign
|
2
assets/lib/smooth-scroll/smooth-scroll.min.js
vendored
Normal file
2
assets/lib/smooth-scroll/smooth-scroll.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -18,7 +18,7 @@ $single-link-color-dark: #55bde2 !default;
|
|||
$code-background-color: #f5f5f5 !default;
|
||||
$code-background-color-dark: #272C34 !default;
|
||||
|
||||
.dark-theme {
|
||||
.dark {
|
||||
// copied from https://github.com/xCss/Valine/issues/221
|
||||
.v *,
|
||||
.v .vwrap .vheader .vinput,
|
||||
|
|
|
@ -93,6 +93,17 @@ enableEmoji = true
|
|||
keywords = ["Theme", "Hugo"]
|
||||
# site default theme ("light", "dark", "auto")
|
||||
defaultTheme = "auto"
|
||||
# Search
|
||||
[languages.en.params.search]
|
||||
enable = true
|
||||
# type of search engine ("lunr", "algolia")
|
||||
type = "algolia"
|
||||
# index length of the content
|
||||
contentLength = 5000
|
||||
[languages.en.params.search.algolia]
|
||||
index = "index.en"
|
||||
appID = "PASDMWALPK"
|
||||
searchKey = "b42948e51daaa93df92381c8e2ac0f93"
|
||||
# Home Page Info
|
||||
[languages.en.params.home]
|
||||
# Home Page Profile
|
||||
|
@ -327,6 +338,17 @@ enableEmoji = true
|
|||
keywords = ["Theme", "Hugo"]
|
||||
# 网站默认主题 ("light", "dark", "auto")
|
||||
defaultTheme = "auto"
|
||||
# 搜索
|
||||
[languages.zh-cn.params.search]
|
||||
enable = true
|
||||
# 搜索引擎的类型 ("lunr", "algolia")
|
||||
type = "algolia"
|
||||
# 文章内容索引长度
|
||||
contentLength = 5000
|
||||
[languages.zh-cn.params.search.algolia]
|
||||
index = "index.zh-cn"
|
||||
appID = "PASDMWALPK"
|
||||
searchKey = "b42948e51daaa93df92381c8e2ac0f93"
|
||||
# 主页信息设置
|
||||
[languages.zh-cn.params.home]
|
||||
# 主页个人信息
|
||||
|
@ -561,6 +583,17 @@ enableEmoji = true
|
|||
keywords = ["Thème", "Hugo"]
|
||||
# site default theme ("light", "dark", "auto")
|
||||
defaultTheme = "auto"
|
||||
# Search
|
||||
[languages.fr.params.search]
|
||||
enable = true
|
||||
# type of search engine ("lunr", "algolia")
|
||||
type = "algolia"
|
||||
# index length of the content
|
||||
contentLength = 5000
|
||||
[languages.fr.params.search.algolia]
|
||||
index = "index.fr"
|
||||
appID = "PASDMWALPK"
|
||||
searchKey = "b42948e51daaa93df92381c8e2ac0f93"
|
||||
# Home Page Info
|
||||
[languages.fr.params.home]
|
||||
# Home Page Profile
|
||||
|
@ -847,6 +880,12 @@ enableEmoji = true
|
|||
animateCSS = ''
|
||||
# smooth-scroll@16.1.2 https://github.com/cferdinandi/smooth-scroll
|
||||
smoothScrollJS = ''
|
||||
# autocomplete.js@0.37.1 https://github.com/algolia/autocomplete.js
|
||||
autocompleteJS = ''
|
||||
# lunr.js@2.3.8 https://lunrjs.com/
|
||||
lunrJS = ''
|
||||
# algoliasearch@4.1.0 https://github.com/algolia/algoliasearch-client-javascript
|
||||
algoliasearchJS = ''
|
||||
# sharer@0.4.0 https://github.com/ellisonleao/sharer.js
|
||||
sharerJS = ''
|
||||
# lazysizes@5.2.0 https://github.com/aFarkas/lazysizes
|
||||
|
@ -858,7 +897,7 @@ enableEmoji = true
|
|||
lightgalleryZoomJS = ''
|
||||
# typeit@6.5.1 https://github.com/alexmacarthur/typeit
|
||||
typeitJS = ''
|
||||
# katex@0.11.1 https://github.com/KaTeX/KaTeX
|
||||
# katex@0.11.1 https://katex.org/
|
||||
katexCSS = ''
|
||||
katexJS = ''
|
||||
katexAutoRenderJS = ''
|
||||
|
@ -867,17 +906,17 @@ enableEmoji = true
|
|||
katexMhchemJS = ''
|
||||
# mermaid@8.4.8 https://github.com/knsv/mermaid
|
||||
mermaidJS = ''
|
||||
# aplayer@1.10.1 https://github.com/MoePlayer/APlayer
|
||||
aplayerCSS = ''
|
||||
aplayerJS = ''
|
||||
# meting@2.0.1 https://github.com/metowolf/MetingJS
|
||||
metingJS = ''
|
||||
# echarts@4.6.0 https://echarts.apache.org/
|
||||
echartsJS = ''
|
||||
echartsMacaronsJS = ''
|
||||
# mapbox-gl@1.8.1 https://docs.mapbox.com/mapbox-gl-js
|
||||
mapboxGLCSS = ''
|
||||
mapboxGLJS = ''
|
||||
# aplayer@1.10.1 https://github.com/MoePlayer/APlayer
|
||||
aplayerCSS = ''
|
||||
aplayerJS = ''
|
||||
# meting@2.0.1 https://github.com/metowolf/MetingJS
|
||||
metingJS = ''
|
||||
# gitalk@1.6.2 https://github.com/gitalk/gitalk
|
||||
gitalkCSS = ''
|
||||
gitalkJS = ''
|
||||
|
@ -962,7 +1001,7 @@ enableEmoji = true
|
|||
# Options to make hugo output files
|
||||
# 用于 Hugo 输出文档的设置
|
||||
[outputs]
|
||||
home = ["HTML", "RSS"]
|
||||
home = ["HTML", "RSS", "JSON"]
|
||||
page = ["HTML", "MarkDown"]
|
||||
section = ["HTML", "RSS"]
|
||||
taxonomy = ["HTML", "RSS"]
|
||||
|
|
|
@ -54,11 +54,12 @@ It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) a
|
|||
|
||||
#### Extended Features
|
||||
|
||||
* :(fas fa-search): **Search** supported by [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/)
|
||||
* :(fas fa-code): Automatically **highlighting** code
|
||||
* :(far fa-images): **Images gallery** supported by [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
|
||||
* :(fab fa-font-awesome): Extended markdown syntax for **[Font Awesome](https://fontawesome.com/) icons**
|
||||
* :(far fa-sticky-note): Extended markdown syntax for **ruby annotation**
|
||||
* :(fas fa-percentage): Extended markdown syntax for **fraction**
|
||||
* :(fab fa-font-awesome): Extended Markdown syntax for **[Font Awesome](https://fontawesome.com/) icons**
|
||||
* :(far fa-sticky-note): Extended Markdown syntax for **ruby annotation**
|
||||
* :(fas fa-percentage): Extended Markdown syntax for **fraction**
|
||||
* :(fas fa-square-root-alt): **Mathematical formula** supported by [$ \KaTeX $](https://katex.org/)
|
||||
* :(fas fa-project-diagram): **Diagrams** shortcode supported by [mermaid](https://github.com/knsv/mermaid)
|
||||
* :(fas fa-chart-pie): **Interactive data visualization** shortcode supported by [ECharts](https://echarts.apache.org/)
|
||||
|
@ -82,9 +83,13 @@ Thanks to the authors of following resources included in the theme:
|
|||
* [Font Awesome](https://fontawesome.com/)
|
||||
* [Fork Awesome](https://forkaweso.me/Fork-Awesome/)
|
||||
* [Animate.css](https://daneden.github.io/animate.css/)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [autocomplete.js](https://github.com/algolia/autocomplete.js)
|
||||
* [Lunr.js](https://lunrjs.com/)
|
||||
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
|
||||
* [Sharer.js](https://github.com/ellisonleao/sharer.js)
|
||||
* [lazysizes](https://github.com/aFarkas/lazysizes)
|
||||
* [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [TypeIt](https://typeitjs.com/)
|
||||
* [$ \KaTeX $](https://katex.org/)
|
||||
* [mermaid](https://github.com/knsv/mermaid)
|
||||
|
|
|
@ -59,11 +59,12 @@ It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) a
|
|||
|
||||
#### Extended Features
|
||||
|
||||
* :(fas fa-search): **Search** supported by [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/)
|
||||
* :(fas fa-code): Automatically **highlighting** code
|
||||
* :(far fa-images): **Images gallery** supported by [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
|
||||
* :(fab fa-font-awesome): Extended markdown syntax for **[Font Awesome](https://fontawesome.com/) icons**
|
||||
* :(far fa-sticky-note): Extended markdown syntax for **ruby annotation**
|
||||
* :(fas fa-percentage): Extended markdown syntax for **fraction**
|
||||
* :(fab fa-font-awesome): Extended Markdown syntax for **[Font Awesome](https://fontawesome.com/) icons**
|
||||
* :(far fa-sticky-note): Extended Markdown syntax for **ruby annotation**
|
||||
* :(fas fa-percentage): Extended Markdown syntax for **fraction**
|
||||
* :(fas fa-square-root-alt): **Mathematical formula** supported by [$ \KaTeX $](https://katex.org/)
|
||||
* :(fas fa-project-diagram): **Diagrams** shortcode supported by [mermaid](https://github.com/knsv/mermaid)
|
||||
* :(fas fa-chart-pie): **Interactive data visualization** shortcode supported by [ECharts](https://echarts.apache.org/)
|
||||
|
@ -87,9 +88,13 @@ Thanks to the authors of following resources included in the theme:
|
|||
* [Font Awesome](https://fontawesome.com/)
|
||||
* [Fork Awesome](https://forkaweso.me/Fork-Awesome/)
|
||||
* [Animate.css](https://daneden.github.io/animate.css/)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [autocomplete.js](https://github.com/algolia/autocomplete.js)
|
||||
* [Lunr.js](https://lunrjs.com/)
|
||||
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
|
||||
* [Sharer.js](https://github.com/ellisonleao/sharer.js)
|
||||
* [lazysizes](https://github.com/aFarkas/lazysizes)
|
||||
* [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [TypeIt](https://typeitjs.com/)
|
||||
* [$ \KaTeX $](https://katex.org/)
|
||||
* [mermaid](https://github.com/knsv/mermaid)
|
||||
|
|
|
@ -54,6 +54,7 @@ lightgallery: true
|
|||
|
||||
#### 扩展功能
|
||||
|
||||
* :(fas fa-search): 支持基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/) 的**搜索**
|
||||
* :(fas fa-code): 支持**代码高亮**
|
||||
* :(far fa-images): 支持基于 [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js) 的**图片画廊**
|
||||
* :(fab fa-font-awesome): 支持 **[Font Awesome](https://fontawesome.com/) 图标**的扩展 Markdown 语法
|
||||
|
@ -82,9 +83,13 @@ LoveIt 主题中用到了以下项目,感谢它们的作者:
|
|||
* [Font Awesome](https://fontawesome.com/)
|
||||
* [Fork Awesome](https://forkaweso.me/Fork-Awesome/)
|
||||
* [Animate.css](https://daneden.github.io/animate.css/)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [autocomplete.js](https://github.com/algolia/autocomplete.js)
|
||||
* [Lunr.js](https://lunrjs.com/)
|
||||
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
|
||||
* [Sharer.js](https://github.com/ellisonleao/sharer.js)
|
||||
* [lazysizes](https://github.com/aFarkas/lazysizes)
|
||||
* [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
|
||||
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||
* [TypeIt](https://typeitjs.com/)
|
||||
* [$ \KaTeX $](https://katex.org/)
|
||||
* [mermaid](https://github.com/knsv/mermaid)
|
||||
|
|
|
@ -204,6 +204,17 @@ Note that some of these parameters are explained in details in other sections of
|
|||
# {{< version 0.1.1 new small >}} which hash function used for SRI, when empty, no SRI is used
|
||||
# ("sha256", "sha384", "sha512", "md5")
|
||||
fingerprint = ""
|
||||
# {{< version 0.2.0 new small >}} Search
|
||||
[params.search]
|
||||
enable = true
|
||||
# type of search engine ("lunr", "algolia")
|
||||
type = "lunr"
|
||||
# index length of the content
|
||||
contentLength = 5000
|
||||
[params.search.algolia]
|
||||
index = ""
|
||||
appID = ""
|
||||
searchKey = ""
|
||||
# Header info
|
||||
[params.header]
|
||||
# desktop header mode ("fixed", "normal", "auto")
|
||||
|
@ -455,6 +466,12 @@ Note that some of these parameters are explained in details in other sections of
|
|||
animateCSS = ''
|
||||
# {{< link "https://github.com/cferdinandi/smooth-scroll" "smooth-scroll" >}}@16.1.2
|
||||
smoothScrollJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://github.com/algolia/autocomplete.js" "autocomplete.js" >}}@0.37.1
|
||||
autocompleteJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://lunrjs.com/" "lunr.js" >}}@2.3.8
|
||||
lunrJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://github.com/algolia/algoliasearch-client-javascript" "algoliasearch" >}}@4.1.0
|
||||
algoliasearchJS = ''
|
||||
# {{< link "https://github.com/ellisonleao/sharer.js" "sharer" >}}@0.4.0
|
||||
sharerJS = ''
|
||||
# {{< link "https://github.com/aFarkas/lazysizes" "lazysizes" >}}@5.2.0
|
||||
|
@ -475,17 +492,17 @@ Note that some of these parameters are explained in details in other sections of
|
|||
katexMhchemJS = ''
|
||||
# {{< link "https://github.com/knsv/mermaid" "mermaid" >}}@8.4.8
|
||||
mermaidJS = ''
|
||||
# {{< link "https://github.com/MoePlayer/APlayer" "aplayer" >}}@1.10.1
|
||||
aplayerCSS = ''
|
||||
aplayerJS = ''
|
||||
# {{< link "https://github.com/metowolf/MetingJS" "meting" >}}@2.0.1
|
||||
metingJS = ''
|
||||
# {{< link "https://echarts.apache.org/" "echarts" >}}@4.6.0
|
||||
echartsJS = ''
|
||||
echartsMacaronsJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://docs.mapbox.com/mapbox-gl-js" mapbox-gl >}}@1.8.1
|
||||
mapboxGLCSS = ''
|
||||
mapboxGLJS = ''
|
||||
# {{< link "https://github.com/MoePlayer/APlayer" "aplayer" >}}@1.10.1
|
||||
aplayerCSS = ''
|
||||
aplayerJS = ''
|
||||
# {{< link "https://github.com/metowolf/MetingJS" "meting" >}}@2.0.1
|
||||
metingJS = ''
|
||||
# {{< link "https://github.com/gitalk/gitalk" "gitalk" >}}@1.6.2
|
||||
gitalkCSS = ''
|
||||
gitalkJS = ''
|
||||
|
@ -558,13 +575,24 @@ Note that some of these parameters are explained in details in other sections of
|
|||
|
||||
# Options to make hugo output files
|
||||
[outputs]
|
||||
home = ["HTML", "RSS"]
|
||||
# {{< version 0.2.0 changed small >}}
|
||||
home = ["HTML", "RSS", "JSON"]
|
||||
page = ["HTML", "MarkDown"]
|
||||
section = ["HTML", "RSS"]
|
||||
taxonomy = ["HTML", "RSS"]
|
||||
taxonomyTerm = ["HTML"]
|
||||
```
|
||||
|
||||
{{< admonition tip "Tips about CDN Configuration" >}}
|
||||
Full HTML tags or URLs are supported for CDN configuration:
|
||||
|
||||
```toml
|
||||
smoothScrollJS = '<script src="https://cdn.jsdelivr.net/npm/smooth-scroll@16.1.3/dist/smooth-scroll.min.js" integrity="sha256-vP+F+14A1ogChQs5Osd5LJl/ci9TbzjiZjjEbcqOXrY=" crossorigin="anonymous"></script>'
|
||||
# Or
|
||||
smoothScrollJS = 'https://cdn.jsdelivr.net/npm/smooth-scroll@16/dist/smooth-scroll.min.js'
|
||||
```
|
||||
{{< /admonition >}}
|
||||
|
||||

|
||||
|
||||
### 3.2 Favicons, Browserconfig, Manifest
|
||||
|
@ -733,3 +761,50 @@ Translations strings are used for common default values used in the theme. Trans
|
|||
To override these values, create a new file in your local i18n folder `i18n/<languageCode>.toml` and inspire yourself from `themes/LoveIt/i18n/en.toml`.
|
||||
|
||||
By the way, as these translations could be used by other people, please take the time to propose a translation by [making a PR](https://github.com/dillonzq/LoveIt/pulls) to the theme!
|
||||
|
||||
## 5 Search
|
||||
|
||||
{{< version 0.2.0 >}}
|
||||
|
||||
Based on [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/), searching is supported in **LoveIt** theme.
|
||||
|
||||
### 5.1 Output Configuration
|
||||
|
||||
In order to generate `index.json` for searching, add `JSON` output file type to the `home` of the `outputs` part in your [site configuration](#site-configuration).
|
||||
|
||||
```toml
|
||||
[outputs]
|
||||
home = ["HTML", "RSS", "JSON"]
|
||||
```
|
||||
|
||||
### 5.2 Search Configuration
|
||||
|
||||
Based on `index.json` generated by Hugo, you could activate searching.
|
||||
|
||||
Here is the search configuration in your [site configuration](#site-configuration):
|
||||
|
||||
```toml
|
||||
[params.search]
|
||||
enable = true
|
||||
# type of search engine ("lunr", "algolia")
|
||||
type = "lunr"
|
||||
# index length of the content
|
||||
contentLength = 5000
|
||||
[params.search.algolia]
|
||||
index = ""
|
||||
appID = ""
|
||||
searchKey = ""
|
||||
```
|
||||
|
||||
{{< admonition note "How to choose the type of search engine?" >}}
|
||||
* `lunr`: simple, no need to synchronize `index.json`, no limit for `contentLength`,
|
||||
but high bandwidth and low performance (Especially for Chinese which needs a large segmentit library)
|
||||
* `algolia`: high performance and low bandwidth, but need to synchronize `index.json` and limit for `contentLength`
|
||||
{{< /admonition >}}
|
||||
|
||||
{{< admonition tip "Tips about algolia" >}}
|
||||
You need to upload `index.json` files to algolia to activate searching.
|
||||
You could upload the `index.json` files by browsers but a script may be a better choice.
|
||||
To be compatible with Hugo multilingual mode,
|
||||
you need to upload different `index.json` for each language to the different index of algolia, such as `zh-cn/index.json` or `fr/index.json`...
|
||||
{{< /admonition >}}
|
||||
|
|
|
@ -209,6 +209,17 @@ Note that some of these parameters are explained in details in other sections of
|
|||
# {{< version 0.1.1 new small >}} which hash function used for SRI, when empty, no SRI is used
|
||||
# ("sha256", "sha384", "sha512", "md5")
|
||||
fingerprint = ""
|
||||
# {{< version 0.2.0 new small >}} Search
|
||||
[params.search]
|
||||
enable = true
|
||||
# type of search engine ("lunr", "algolia")
|
||||
type = "lunr"
|
||||
# index length of the content
|
||||
contentLength = 5000
|
||||
[params.search.algolia]
|
||||
index = ""
|
||||
appID = ""
|
||||
searchKey = ""
|
||||
# Header info
|
||||
[params.header]
|
||||
# desktop header mode ("fixed", "normal", "auto")
|
||||
|
@ -460,6 +471,12 @@ Note that some of these parameters are explained in details in other sections of
|
|||
animateCSS = ''
|
||||
# {{< link "https://github.com/cferdinandi/smooth-scroll" "smooth-scroll" >}}@16.1.2
|
||||
smoothScrollJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://github.com/algolia/autocomplete.js" "autocomplete.js" >}}@0.37.1
|
||||
autocompleteJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://lunrjs.com/" "lunr.js" >}}@2.3.8
|
||||
lunrJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://github.com/algolia/algoliasearch-client-javascript" "algoliasearch" >}}@4.1.0
|
||||
algoliasearchJS = ''
|
||||
# {{< link "https://github.com/ellisonleao/sharer.js" "sharer" >}}@0.4.0
|
||||
sharerJS = ''
|
||||
# {{< link "https://github.com/aFarkas/lazysizes" "lazysizes" >}}@5.2.0
|
||||
|
@ -480,17 +497,17 @@ Note that some of these parameters are explained in details in other sections of
|
|||
katexMhchemJS = ''
|
||||
# {{< link "https://github.com/knsv/mermaid" "mermaid" >}}@8.4.8
|
||||
mermaidJS = ''
|
||||
# {{< link "https://github.com/MoePlayer/APlayer" "aplayer" >}}@1.10.1
|
||||
aplayerCSS = ''
|
||||
aplayerJS = ''
|
||||
# {{< link "https://github.com/metowolf/MetingJS" "meting" >}}@2.0.1
|
||||
metingJS = ''
|
||||
# {{< link "https://echarts.apache.org/" "echarts" >}}@4.6.0
|
||||
echartsJS = ''
|
||||
echartsMacaronsJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://docs.mapbox.com/mapbox-gl-js" mapbox-gl >}}@1.8.1
|
||||
mapboxGLCSS = ''
|
||||
mapboxGLJS = ''
|
||||
# {{< link "https://github.com/MoePlayer/APlayer" "aplayer" >}}@1.10.1
|
||||
aplayerCSS = ''
|
||||
aplayerJS = ''
|
||||
# {{< link "https://github.com/metowolf/MetingJS" "meting" >}}@2.0.1
|
||||
metingJS = ''
|
||||
# {{< link "https://github.com/gitalk/gitalk" "gitalk" >}}@1.6.2
|
||||
gitalkCSS = ''
|
||||
gitalkJS = ''
|
||||
|
@ -563,13 +580,24 @@ Note that some of these parameters are explained in details in other sections of
|
|||
|
||||
# Options to make hugo output files
|
||||
[outputs]
|
||||
home = ["HTML", "RSS"]
|
||||
# {{< version 0.2.0 changed small >}}
|
||||
home = ["HTML", "RSS", "JSON"]
|
||||
page = ["HTML", "MarkDown"]
|
||||
section = ["HTML", "RSS"]
|
||||
taxonomy = ["HTML", "RSS"]
|
||||
taxonomyTerm = ["HTML"]
|
||||
```
|
||||
|
||||
{{< admonition tip "Tips about CDN Configuration" >}}
|
||||
Full HTML tags or URLs are supported for CDN configuration:
|
||||
|
||||
```toml
|
||||
smoothScrollJS = '<script src="https://cdn.jsdelivr.net/npm/smooth-scroll@16.1.3/dist/smooth-scroll.min.js" integrity="sha256-vP+F+14A1ogChQs5Osd5LJl/ci9TbzjiZjjEbcqOXrY=" crossorigin="anonymous"></script>'
|
||||
# Or
|
||||
smoothScrollJS = 'https://cdn.jsdelivr.net/npm/smooth-scroll@16/dist/smooth-scroll.min.js'
|
||||
```
|
||||
{{< /admonition >}}
|
||||
|
||||

|
||||
|
||||
### 3.2 Favicons, Browserconfig, Manifest
|
||||
|
@ -738,3 +766,50 @@ Translations strings are used for common default values used in the theme. Trans
|
|||
To override these values, create a new file in your local i18n folder `i18n/<languageCode>.toml` and inspire yourself from `themes/LoveIt/i18n/en.toml`.
|
||||
|
||||
By the way, as these translations could be used by other people, please take the time to propose a translation by [making a PR](https://github.com/dillonzq/LoveIt/pulls) to the theme!
|
||||
|
||||
## 5 Search
|
||||
|
||||
{{< version 0.2.0 >}}
|
||||
|
||||
Based on [Lunr.js](https://lunrjs.com/) or [algolia](https://www.algolia.com/), searching is supported in **LoveIt** theme.
|
||||
|
||||
### 5.1 Output Configuration
|
||||
|
||||
In order to generate `index.json` for searching, add `JSON` output file type to the `home` of the `outputs` part in your [site configuration](#site-configuration).
|
||||
|
||||
```toml
|
||||
[outputs]
|
||||
home = ["HTML", "RSS", "JSON"]
|
||||
```
|
||||
|
||||
### 5.2 Search Configuration
|
||||
|
||||
Based on `index.json` generated by Hugo, you could activate searching.
|
||||
|
||||
Here is the search configuration in your [site configuration](#site-configuration):
|
||||
|
||||
```toml
|
||||
[params.search]
|
||||
enable = true
|
||||
# type of search engine ("lunr", "algolia")
|
||||
type = "lunr"
|
||||
# index length of the content
|
||||
contentLength = 5000
|
||||
[params.search.algolia]
|
||||
index = ""
|
||||
appID = ""
|
||||
searchKey = ""
|
||||
```
|
||||
|
||||
{{< admonition note "How to choose the type of search engine?" >}}
|
||||
* `lunr`: simple, no need to synchronize `index.json`, no limit for `contentLength`,
|
||||
but high bandwidth and low performance (Especially for Chinese which needs a large segmentit library)
|
||||
* `algolia`: high performance and low bandwidth, but need to synchronize `index.json` and limit for `contentLength`
|
||||
{{< /admonition >}}
|
||||
|
||||
{{< admonition tip "Tips about algolia" >}}
|
||||
You need to upload `index.json` files to algolia to activate searching.
|
||||
You could upload the `index.json` files by browsers but a script may be a better choice.
|
||||
To be compatible with Hugo multilingual mode,
|
||||
you need to upload different `index.json` for each language to the different index of algolia, such as `zh-cn/index.json` or `fr/index.json`...
|
||||
{{< /admonition >}}
|
||||
|
|
|
@ -207,6 +207,17 @@ hugo
|
|||
# {{< version 0.1.1 new small >}} 哪种哈希函数用来 SRI, 为空时表示不使用 SRI
|
||||
# ("sha256", "sha384", "sha512", "md5")
|
||||
fingerprint = ""
|
||||
# {{< version 0.2.0 new small >}} 搜索
|
||||
[params.search]
|
||||
enable = true
|
||||
# 搜索引擎的类型 ("lunr", "algolia")
|
||||
type = "lunr"
|
||||
# 文章内容索引长度
|
||||
contentLength = 5000
|
||||
[params.search.algolia]
|
||||
index = ""
|
||||
appID = ""
|
||||
searchKey = ""
|
||||
# 页面头部导航栏信息
|
||||
[params.header]
|
||||
# 桌面端导航栏模式 ("fixed", "normal", "auto")
|
||||
|
@ -457,6 +468,12 @@ hugo
|
|||
animateCSS = ''
|
||||
# {{< link "https://github.com/cferdinandi/smooth-scroll" "smooth-scroll" >}}@16.1.2
|
||||
smoothScrollJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://github.com/algolia/autocomplete.js" "autocomplete.js" >}}@0.37.1
|
||||
autocompleteJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://lunrjs.com/" "lunr.js" >}}@2.3.8
|
||||
lunrJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://github.com/algolia/algoliasearch-client-javascript" "algoliasearch" >}}@4.1.0
|
||||
algoliasearchJS = ''
|
||||
# {{< link "https://github.com/ellisonleao/sharer.js" "sharer" >}}@0.4.0
|
||||
sharerJS = ''
|
||||
# {{< link "https://github.com/aFarkas/lazysizes" "lazysizes" >}}@5.2.0
|
||||
|
@ -477,17 +494,17 @@ hugo
|
|||
katexMhchemJS = ''
|
||||
# {{< link "https://github.com/knsv/mermaid" "mermaid" >}}@8.4.8
|
||||
mermaidJS = ''
|
||||
# {{< link "https://github.com/MoePlayer/APlayer" "aplayer" >}}@1.10.1
|
||||
aplayerCSS = ''
|
||||
aplayerJS = ''
|
||||
# {{< link "https://github.com/metowolf/MetingJS" "meting" >}}@2.0.1
|
||||
metingJS = ''
|
||||
# {{< link "https://echarts.apache.org/" "echarts" >}}@4.6.0
|
||||
echartsJS = ''
|
||||
echartsMacaronsJS = ''
|
||||
# {{< version 0.2.0 new small >}} {{< link "https://docs.mapbox.com/mapbox-gl-js" mapbox-gl >}}@1.8.1
|
||||
mapboxGLCSS = ''
|
||||
mapboxGLJS = ''
|
||||
# {{< link "https://github.com/MoePlayer/APlayer" "aplayer" >}}@1.10.1
|
||||
aplayerCSS = ''
|
||||
aplayerJS = ''
|
||||
# {{< link "https://github.com/metowolf/MetingJS" "meting" >}}@2.0.1
|
||||
metingJS = ''
|
||||
# {{< link "https://github.com/gitalk/gitalk" "gitalk" >}}@1.6.2
|
||||
gitalkCSS = ''
|
||||
gitalkJS = ''
|
||||
|
@ -560,13 +577,24 @@ hugo
|
|||
|
||||
# 用于 Hugo 输出文档的设置
|
||||
[outputs]
|
||||
home = ["HTML", "RSS"]
|
||||
# {{< version 0.2.0 changed small >}}
|
||||
home = ["HTML", "RSS", "JSON"]
|
||||
page = ["HTML", "MarkDown"]
|
||||
section = ["HTML", "RSS"]
|
||||
taxonomy = ["HTML", "RSS"]
|
||||
taxonomyTerm = ["HTML"]
|
||||
```
|
||||
|
||||
{{< admonition tip "关于 CDN 配置的技巧" >}}
|
||||
在 CDN 的配置中, 完整的 HTML 标签和 URL 都是支持的:
|
||||
|
||||
```toml
|
||||
smoothScrollJS = '<script src="https://cdn.jsdelivr.net/npm/smooth-scroll@16.1.3/dist/smooth-scroll.min.js" integrity="sha256-vP+F+14A1ogChQs5Osd5LJl/ci9TbzjiZjjEbcqOXrY=" crossorigin="anonymous"></script>'
|
||||
# 或者
|
||||
smoothScrollJS = 'https://cdn.jsdelivr.net/npm/smooth-scroll@16/dist/smooth-scroll.min.js'
|
||||
```
|
||||
{{< /admonition >}}
|
||||
|
||||

|
||||
|
||||
### 3.2 网站图标, 浏览器配置, 网站清单
|
||||
|
@ -736,3 +764,47 @@ defaultContentLanguage = "zh-cn"
|
|||
要覆盖默认值, 请在项目的 i18n 目录 `i18n/<languageCode>.toml` 中创建一个新文件,并从 `themes/LoveIt/i18n/en.toml` 中获得提示.
|
||||
|
||||
另外, 由于你的翻译可能会帮助到其他人, 请花点时间通过 [创建一个 PR](https://github.com/dillonzq/LoveIt/pulls) 来贡献主题翻译, 谢谢!
|
||||
|
||||
## 5 搜索
|
||||
|
||||
{{< version 0.2.0 >}}
|
||||
|
||||
基于 [Lunr.js](https://lunrjs.com/) 或 [algolia](https://www.algolia.com/), **LoveIt** 主支持搜索功能.
|
||||
|
||||
### 5.1 输出配置
|
||||
|
||||
为了生成搜索功能所需要的 `index.json`, 请在你的 [网站配置](#site-configuration) 中添加 `JSON` 输出文件类型到 `outputs` 部分的 `home` 字段中.
|
||||
|
||||
```toml
|
||||
[outputs]
|
||||
home = ["HTML", "RSS", "JSON"]
|
||||
```
|
||||
|
||||
### 5.2 搜索配置
|
||||
|
||||
基于 Hugo 生成的 `index.json` 文件, 你可以激活搜索功能.
|
||||
|
||||
这是你的 [网站配置](#site-configuration) 中的搜索部分:
|
||||
|
||||
```toml
|
||||
[params.search]
|
||||
enable = true
|
||||
# type of search engine ("lunr", "algolia")
|
||||
type = "lunr"
|
||||
# index length of the content
|
||||
contentLength = 5000
|
||||
[params.search.algolia]
|
||||
index = ""
|
||||
appID = ""
|
||||
searchKey = ""
|
||||
```
|
||||
|
||||
{{< admonition note "怎样选择搜索引擎的类型?" >}}
|
||||
* `lunr`: 简单, 无需同步 `index.json`, 没有 `contentLength` 的限制, 但占用带宽大且性能低 (特别是中文需要一个较大的分词依赖库)
|
||||
* `algolia`: 高性能并且占用带宽低, 但需要同步 `index.json` 且有 `contentLength` 的限制
|
||||
{{< /admonition >}}
|
||||
|
||||
{{< admonition tip "关于 algolia 的使用技巧" >}}
|
||||
你需要上传 `index.json` 到 algolia 来激活搜索功能. 你可以使用浏览器来上传 `index.json` 文件但是一个自动化的脚本可能是更好的选择.
|
||||
为了兼容 Hugo 的多语言模式, 你需要上传不同语言的 `index.json` 文件到对应的 algolia index, 例如 `zh-cn/index.json` 或 `fr/index.json`...
|
||||
{{< /admonition >}}
|
||||
|
|
|
@ -68,6 +68,7 @@ license: ""
|
|||
tags: []
|
||||
categories: []
|
||||
hiddenFromHomePage: false
|
||||
hiddenFromSearch: false
|
||||
|
||||
featuredImage: ""
|
||||
featuredImagePreview: ""
|
||||
|
@ -103,6 +104,7 @@ comment: true
|
|||
* **tags**: the tags for the content.
|
||||
* **categories**: the categories for the content.
|
||||
* **hiddenFromHomePage**: if `true`, the content will not be shown in the home page, but this behaviour is configurabl in the [site configuration](../theme-documentation-basics/#site-configuration).
|
||||
* **hiddenFromSearch**: {{< version 0.2.0 >}} if `true`, the content will not be shown in the search results.
|
||||
* **featuredImage**: the featured image for the content.
|
||||
* **featuredImagePreview**: the featured image for the content preview in the home page.
|
||||
* **toc**: if `true`, the content will show the table of the contents.
|
||||
|
@ -114,6 +116,10 @@ comment: true
|
|||
* **share**: the same as `params.share` in the [site configuration](../theme-documentation-basics/#site-configuration).
|
||||
* **comment**: if `true`, the comment will be used.
|
||||
|
||||
{{< admonition tip >}}
|
||||
Not all of the above front matters need to be set in each of your posts. It is necessary only if the front matters and your [site configuration](../theme-documentation-basics/#site-configuration) are inconsistent.
|
||||
{{< /admonition >}}
|
||||
|
||||
## 3 Content Summaries
|
||||
|
||||
**LoveIt** theme uses the summary of the content to display abstract information in the home page. Hugo can generate summaries of your content.
|
||||
|
|
|
@ -73,6 +73,7 @@ license: ""
|
|||
tags: []
|
||||
categories: []
|
||||
hiddenFromHomePage: false
|
||||
hiddenFromSearch: false
|
||||
|
||||
featuredImage: ""
|
||||
featuredImagePreview: ""
|
||||
|
@ -108,6 +109,7 @@ comment: true
|
|||
* **tags**: the tags for the content.
|
||||
* **categories**: the categories for the content.
|
||||
* **hiddenFromHomePage**: if `true`, the content will not be shown in the home page, but this behaviour is configurabl in the [site configuration](../theme-documentation-basics/#site-configuration).
|
||||
* **hiddenFromSearch**: {{< version 0.2.0 >}} if `true`, the content will not be shown in the search results.
|
||||
* **featuredImage**: the featured image for the content.
|
||||
* **featuredImagePreview**: the featured image for the content preview in the home page.
|
||||
* **toc**: if `true`, the content will show the table of the contents.
|
||||
|
@ -119,6 +121,10 @@ comment: true
|
|||
* **share**: the same as `params.share` in the [site configuration](../theme-documentation-basics/#site-configuration).
|
||||
* **comment**: if `true`, the comment will be used.
|
||||
|
||||
{{< admonition tip >}}
|
||||
Not all of the above front matters need to be set in each of your posts. It is necessary only if the front matters and your [site configuration](../theme-documentation-basics/#site-configuration) are inconsistent.
|
||||
{{< /admonition >}}
|
||||
|
||||
## 3 Content Summaries
|
||||
|
||||
**LoveIt** theme uses the summary of the content to display abstract information in the home page. Hugo can generate summaries of your content.
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
weight: 2
|
||||
title: "主题文档 - 内容"
|
||||
subtitle: ""
|
||||
date: 2020-03-05T16:30:05+08:00
|
||||
lastmod: 2020-03-05T16:30:05+08:00
|
||||
draft: false
|
||||
|
@ -12,18 +11,13 @@ license: ""
|
|||
|
||||
tags: ["内容", "markdown"]
|
||||
categories: ["documentation"]
|
||||
hiddenFromHomePage: false
|
||||
|
||||
featuredImage: "/images/theme-documentation-content/featured-image.jpg"
|
||||
featuredImagePreview: ""
|
||||
|
||||
toc: true
|
||||
autoCollapseToc: false
|
||||
math: true
|
||||
mapbox:
|
||||
accessToken: ""
|
||||
lightStyle: ""
|
||||
darkStyle: ""
|
||||
navigation: true
|
||||
geolocate: true
|
||||
scale: true
|
||||
|
@ -68,6 +62,7 @@ license: ""
|
|||
tags: []
|
||||
categories: []
|
||||
hiddenFromHomePage: false
|
||||
hiddenFromSearch: false
|
||||
|
||||
featuredImage: ""
|
||||
featuredImagePreview: ""
|
||||
|
@ -103,6 +98,7 @@ comment: true
|
|||
* **tags**: 文章的标签.
|
||||
* **categories**: 文章所属的类别.
|
||||
* **hiddenFromHomePage**: 如果设为 `true`, 这篇文章将不会显示在主页上, 但是此行为可以在 [网站配置](../theme-documentation-basics/#site-configuration) 中设置的.
|
||||
* **hiddenFromSearch**: {{< version 0.2.0 >}} 如果设为 `true`, 这篇文章将不会显示在搜索结果中.
|
||||
* **featuredImage**: 文章的特色图片.
|
||||
* **featuredImagePreview**: 用在主页预览的文章特色图片.
|
||||
* **toc**: 如果设为 `true`, 这篇文章会显示右侧目录.
|
||||
|
@ -114,6 +110,11 @@ comment: true
|
|||
* **share**: 和 [网站配置](../theme-documentation-basics/#site-configuration) 中的 `params.share` 对象相同.
|
||||
* **comment**: 如果设为 `true`, 将启用评论系统.
|
||||
|
||||
{{< admonition tip >}}
|
||||
不是所有的上述前置参数都必须在你的每篇文章中设置.
|
||||
只有在文章的参数和你的 [网站设置](../theme-documentation-basics/#site-configuration) 不一致时才有必要这么做.
|
||||
{{< /admonition >}}
|
||||
|
||||
## 3 内容摘要
|
||||
|
||||
**LoveIt** 主题使用内容摘要在主页中显示大致文章信息。Hugo 支持生成文章的摘要.
|
||||
|
|
|
@ -12,7 +12,6 @@ license: ""
|
|||
|
||||
tags: ["shortcodes"]
|
||||
categories: ["documentation"]
|
||||
hiddenFromHomePage: false
|
||||
|
||||
featuredImage: "/images/theme-documentation-extended-shortcodes/featured-image.jpg"
|
||||
featuredImagePreview: "/images/theme-documentation-extended-shortcodes/featured-image-preview.jpg"
|
||||
|
@ -20,19 +19,6 @@ featuredImagePreview: "/images/theme-documentation-extended-shortcodes/featured-
|
|||
toc: true
|
||||
autoCollapseToc: true
|
||||
math: false
|
||||
mapbox:
|
||||
accessToken: ""
|
||||
lightStyle: ""
|
||||
darkStyle: ""
|
||||
navigation: true
|
||||
geolocate: true
|
||||
scale: true
|
||||
fullscreen: true
|
||||
lightgallery: true
|
||||
linkToMarkdown: true
|
||||
share:
|
||||
enable: true
|
||||
comment: true
|
||||
---
|
||||
|
||||
**LoveIt** 主题在 Hugo 内置的 shortcode 的基础上提供多个扩展的 shortcode.
|
||||
|
|
15
i18n/en.toml
15
i18n/en.toml
|
@ -40,6 +40,21 @@ other = "More"
|
|||
[selectLanguage]
|
||||
other = "Select Language"
|
||||
|
||||
[search]
|
||||
other = "Search"
|
||||
|
||||
[searchPlaceholder]
|
||||
other = "Search titles or contents..."
|
||||
|
||||
[clear]
|
||||
other = "Clear"
|
||||
|
||||
[cancel]
|
||||
other = "Cancel"
|
||||
|
||||
[noResultsFound]
|
||||
other = "No results found"
|
||||
|
||||
[switchTheme]
|
||||
other = "Switch Theme"
|
||||
# === partials/header.html ===
|
||||
|
|
23
i18n/fr.toml
23
i18n/fr.toml
|
@ -40,6 +40,21 @@ other = "Plus"
|
|||
[selectLanguage]
|
||||
other = "Choisir la langue"
|
||||
|
||||
[search]
|
||||
other = "Chercher"
|
||||
|
||||
[searchPlaceholder]
|
||||
other = "Rechercher des titres, des contenus..."
|
||||
|
||||
[clear]
|
||||
other = "Clair"
|
||||
|
||||
[cancel]
|
||||
other = "Annuler"
|
||||
|
||||
[noResultsFound]
|
||||
other = "Aucun résultat trouvé"
|
||||
|
||||
[switchTheme]
|
||||
other = "Changer de Thème"
|
||||
# === partials/header.html ===
|
||||
|
@ -52,6 +67,14 @@ other = "Propulsé par %s"
|
|||
other = "Thème"
|
||||
# === partials/footer.html ===
|
||||
|
||||
# === partials/assets.html ===
|
||||
[lunrLanguageLib]
|
||||
other = "lib/lunr/lunr.fr.js"
|
||||
|
||||
[lunrLanguageCode]
|
||||
other = "fr"
|
||||
# === partials/assets.html ===
|
||||
|
||||
# === partials/plugin/share.html ===
|
||||
[shareOn]
|
||||
other = "Partager sur"
|
||||
|
|
|
@ -40,6 +40,21 @@ other = "更多"
|
|||
[selectLanguage]
|
||||
other = "选择语言"
|
||||
|
||||
[search]
|
||||
other = "搜索"
|
||||
|
||||
[searchPlaceholder]
|
||||
other = "搜索文章标题或内容..."
|
||||
|
||||
[clear]
|
||||
other = "清空"
|
||||
|
||||
[cancel]
|
||||
other = "取消"
|
||||
|
||||
[noResultsFound]
|
||||
other = "没有找到结果"
|
||||
|
||||
[switchTheme]
|
||||
other = "切换主题"
|
||||
# === partials/header.html ===
|
||||
|
@ -52,6 +67,14 @@ other = "由 %s 强力驱动"
|
|||
other = "主题"
|
||||
# === partials/footer.html ===
|
||||
|
||||
# === partials/assets.html ===
|
||||
[lunrLanguageLib]
|
||||
other = "lib/lunr/lunr.zh.js"
|
||||
|
||||
[lunrLanguageCode]
|
||||
other = "zh"
|
||||
# === partials/assets.html ===
|
||||
|
||||
# === partials/plugin/share.html ===
|
||||
[shareOn]
|
||||
other = "分享到"
|
||||
|
|
|
@ -10,13 +10,10 @@
|
|||
<a href="{{ `/` | relLangURL }}" title="{{ T `backToHome` }}">↩︎</a>
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
var emojiArray = [
|
||||
'\\(o_o)/', '(o^^)o', '(˚Δ˚)b', '(^-^*)', '(≥o≤)', '(^_^)b', '(·_·)',
|
||||
'(=\'X\'=)', '(>_<)', '(;-;)', '\\(^Д^)/',
|
||||
];
|
||||
var errorEmoji = emojiArray[Math.floor(Math.random() * emojiArray.length)];
|
||||
var errorEmojiContainer = document.getElementById('error-emoji');
|
||||
errorEmojiContainer.appendChild(document.createTextNode(errorEmoji));
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var emojiArray = ['\\(o_o)/', '(o^^)o', '(˚Δ˚)b', '(^-^*)', '(≥o≤)', '(^_^)b', '(·_·)','(=\'X\'=)', '(>_<)', '(;-;)', '\\(^Д^)/'];
|
||||
document.getElementById('error-emoji').appendChild(document.createTextNode(emojiArray[Math.floor(Math.random() * emojiArray.length)]));
|
||||
})();
|
||||
</script>
|
||||
{{- end -}}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
{{- /* Content */ -}}
|
||||
<div class="content" id="content">
|
||||
{{- partial "single/content.html" .Content -}}
|
||||
{{- partial "function/content.html" .Content | safeHTML -}}
|
||||
</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
{{- /* Summary content */ -}}
|
||||
<div class="content">
|
||||
{{- with .Summary -}}
|
||||
{{- partial "single/content.html" . -}}
|
||||
{{- partial "function/content.html" . | safeHTML -}}
|
||||
{{- else -}}
|
||||
{{- .Description | safeHTML -}}
|
||||
{{- end -}}
|
||||
|
|
15
layouts/index.json
Normal file
15
layouts/index.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{{- $index := slice -}}
|
||||
{{- range where .Site.RegularPages ".Params.hiddenfromsearch" "!=" true -}}
|
||||
{{- $one := dict "uri" .RelPermalink "title" .Title "description" (.Description | default "") -}}
|
||||
{{- $tags := .Params.tags | default slice -}}
|
||||
{{- $one = delimit $tags "\n" | dict "tags" | merge $one -}}
|
||||
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
|
||||
{{- $one = dict "date" $publish_date | merge $one -}}
|
||||
{{- $content := partial "function/content.html" .Content | plainify -}}
|
||||
{{- if gt .Site.Params.search.contentLength 0 -}}
|
||||
{{- $content = substr $content 0 .Site.Params.search.contentLength -}}
|
||||
{{- end -}}
|
||||
{{- $one = dict "content" $content | merge $one -}}
|
||||
{{- $index = $index | append $one -}}
|
||||
{{- end -}}
|
||||
{{- $index | jsonify | safeJS -}}
|
|
@ -1,219 +1,241 @@
|
|||
{{- $scratch := .Scratch.Get "scratch" -}}
|
||||
{{- $CDN := $scratch.Get "CDN" -}}
|
||||
{{- $fingerprint := $scratch.Get "fingerprint" -}}
|
||||
{{- $config := dict "desktopHeaderMode" .Site.Params.header.desktopMode "mobileHeaderMode" .Site.Params.header.mobileMode -}}
|
||||
{{- with $scratch.Get "contentData" -}}
|
||||
{{- $config = dict "content" . | merge $config -}}
|
||||
{{- end -}}
|
||||
{{- with $scratch.Get "comment" -}}
|
||||
{{- $config = dict "comment" . | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Fork Awesome */ -}}
|
||||
{{- if $scratch.Get "forkawesome" -}}
|
||||
{{- slice "lib/forkawesome/fork-awesome.scss" | $scratch.Add "linkLocal" -}}
|
||||
{{- $options := dict "targetPath" "lib/forkawesome/fork-awesome.min.css" -}}
|
||||
{{- dict "source" "lib/forkawesome/fork-awesome.scss" "toCSS" $options "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* iconfont */ -}}
|
||||
{{- if $scratch.Get "iconfont" -}}
|
||||
{{- with $CDN.iconfontCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/iconfont/iconfont.css" | $scratch.Add "linkLocal" -}}
|
||||
{{- dict "source" "lib/iconfont/iconfont.css" "minify" true "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Smooth Scroll */ -}}
|
||||
{{- with $CDN.smoothScrollJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/smooth-scroll/smooth-scroll.polyfills.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/smooth-scroll/smooth-scroll.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Sharer.js */ -}}
|
||||
{{- if $scratch.Get "share" -}}
|
||||
{{- with $CDN.sharerJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- /* Search */ -}}
|
||||
{{- if .Site.Params.search.enable -}}
|
||||
{{- with $CDN.autocompleteJS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/sharer/sharer.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/autocomplete/autocomplete.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- $searchConfig := dict "noResultsFound" (T "noResultsFound") -}}
|
||||
{{- if eq .Site.Params.search.type "lunr" -}}
|
||||
{{- with .Site.Home.OutputFormats.Get "json" -}}
|
||||
{{- $searchConfig = dict "type" "lunr" "lunrIndexURL" .RelPermalink | merge $searchConfig -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.lunrJS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- dict "source" "lib/lunr/lunr.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- if ne .Language.Lang "en" -}}
|
||||
{{- $searchConfig = T "lunrLanguageCode" | dict "lunrLanguageCode" | merge $searchConfig -}}
|
||||
{{- if eq .Language.Lang "zh-cn" -}}
|
||||
{{- $searchConfig = dict "lunrSegmentitURL" (resources.Get "lib/lunr/lunr.segmentit.js").RelPermalink | merge $searchConfig -}}
|
||||
{{- end -}}
|
||||
{{- dict "source" "lib/lunr/lunr.stemmer.support.js" "minify" true "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- dict "source" (T "lunrLanguageLib") "minify" true "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- else if eq .Site.Params.search.type "algolia" -}}
|
||||
{{- with $CDN.algoliasearchJS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- dict "source" "lib/algoliasearch/algoliasearch-lite.umd.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- $searchConfig = dict "type" "algolia" "algoliaIndex" .Site.Params.search.algolia.index "algoliaAppID" .Site.Params.search.algolia.appID "algoliaSearchKey" .Site.Params.search.algolia.searchKey | merge $searchConfig -}}
|
||||
{{- end -}}
|
||||
{{- $config = dict "search" $searchConfig | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* lazysizes */ -}}
|
||||
{{- with $CDN.lazysizesJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/lazysizes/lazysizes.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/lazysizes/lazysizes.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* lightgallery.js */ -}}
|
||||
{{- if ne .Site.Params.page.lightgallery false | and (ne .Params.lightgallery false) -}}
|
||||
{{- with $CDN.lightgalleryCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/lightgallery/lightgallery.min.css" | $scratch.Add "linkLocal" -}}
|
||||
{{- dict "source" "lib/lightgallery/lightgallery.min.css" "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.lightgalleryJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/lightgallery/lightgallery.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/lightgallery/lightgallery.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.lightgalleryThumbnailJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/lightgallery/lg-thumbnail.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/lightgallery/lg-thumbnail.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.lightgalleryZoomJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/lightgallery/lg-zoom.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/lightgallery/lg-zoom.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- $lightGalleryConfig := dict "selector" ".lightgallery" "speed" 400 "hideBarsDelay" 2000 "thumbnail" true "exThumbImage" "data-thumbnail" "thumbWidth" 80 "thumbContHeight" 80 "actualSize" false -}}
|
||||
{{- $config = dict "lightGallery" $lightGalleryConfig | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Sharer.js */ -}}
|
||||
{{- if $scratch.Get "share" -}}
|
||||
{{- with $CDN.sharerJS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- dict "source" "lib/sharer/sharer.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
lightGallery(document.getElementById('content'), {
|
||||
selector: '.lightgallery',
|
||||
speed: 400,
|
||||
hideBarsDelay: 2000,
|
||||
thumbnail: true,
|
||||
exThumbImage: 'data-thumbnail',
|
||||
thumbWidth: 80,
|
||||
thumbContHeight: 80,
|
||||
actualSize: false,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* TypeIt */ -}}
|
||||
{{- with $scratch.Get "typeitMap" -}}
|
||||
{{- with $CDN.typeitJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/typeit/typeit.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/typeit/typeit.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- $typeitConfig := slice -}}
|
||||
{{- range $key, $val := . -}}
|
||||
{{- slice $val | $scratch.Add "typeitArr" -}}
|
||||
{{- $typeitConfig = $typeitConfig | append (slice $val) -}}
|
||||
{{- end -}}
|
||||
<script>
|
||||
window.typeitArr = {{ $scratch.Get "typeitArr" | jsonify | safeJS }};
|
||||
</script>
|
||||
{{- $config = dict "typeit" $typeitConfig | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* KaTeX */ -}}
|
||||
{{- if ne .Site.Params.math.enable false | and .Params.math -}}
|
||||
{{- with $CDN.katexCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/katex/katex.min.css" | $scratch.Add "linkLocal" -}}
|
||||
{{- dict "source" "lib/katex/katex.min.css" "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.katexJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/katex/katex.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/katex/katex.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.katexAutoRenderJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/katex/auto-render.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/katex/auto-render.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- $math := .Site.Params.math -}}
|
||||
{{- if $math.copyTex -}}
|
||||
{{- with $CDN.katexCopyTexCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/katex/copy-tex.min.css" | $scratch.Add "linkLocal" -}}
|
||||
{{- dict "source" "lib/katex/copy-tex.min.css" "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.katexCopyTexJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/katex/copy-tex.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/katex/copy-tex.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if $math.mhchem -}}
|
||||
{{- with $CDN.katexMhchemJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/katex/mhchem.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/katex/mhchem.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
renderMathInElement(document.body, {
|
||||
delimiters: [
|
||||
{ left: '$$', right: '$$', display: true },
|
||||
{ left: '\\[', right: '\\]', display: true },
|
||||
{{- if and $math.blockLeftDelimiter $math.blockRightDelimiter -}}
|
||||
{ left: '{{ $math.blockLeftDelimiter }}', right: '{{ $math.blockRightDelimiter }}', display: true },
|
||||
{{- end -}}
|
||||
{ left: '$', right: '$', display: false },
|
||||
{ left: '\\(', right: '\\)', display: false },
|
||||
{{- if and $math.inlineLeftDelimiter $math.inlineRightDelimiter -}}
|
||||
{ left: '{{ $math.inlineLeftDelimiter }}', right: '{{ $math.inlineRightDelimiter }}', display: false },
|
||||
{{- end -}}
|
||||
],
|
||||
strict: false,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{{- $mathConfig := dict "strict" false -}}
|
||||
{{- $delimiters := slice (dict "left" "$$" "right" "$$" "display" true) (dict "left" "\\[" "right" "\\]" "display" true) -}}
|
||||
{{- if and $math.blockLeftDelimiter $math.blockRightDelimiter -}}
|
||||
{{- $delimiters = $delimiters | append (dict "left" $math.blockLeftDelimiter "right" $math.blockRightDelimiter "display" true) -}}
|
||||
{{- end -}}
|
||||
{{- $delimiters = $delimiters | append (dict "left" "$" "right" "$" "display" false) (dict "left" "\\(" "right" "\\)" "display" false) -}}
|
||||
{{- if and $math.inlineLeftDelimiter $math.inlineRightDelimiter -}}
|
||||
{{- $delimiters = $delimiters | append (dict "left" $math.inlineRightDelimiter "right" $math.inlineRightDelimiter "display" false) -}}
|
||||
{{- end -}}
|
||||
{{- $mathConfig = dict "delimiters" $delimiters | merge $mathConfig -}}
|
||||
{{- $config = dict "math" $mathConfig | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* mermaid */ -}}
|
||||
{{- if $scratch.Get "mermaid" -}}
|
||||
{{- with $CDN.mermaidJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/mermaid/mermaid.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/mermaid/mermaid.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- slice "lib/mermaid/mermaid.scss" | $scratch.Add "linkLocal" -}}
|
||||
{{- $options := dict "targetPath" "lib/mermaid/mermaid.min.css" -}}
|
||||
{{- dict "source" "lib/mermaid/mermaid.scss" "toCSS" $options "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* ECharts */ -}}
|
||||
{{- if $scratch.Get "echarts" -}}
|
||||
{{- with $CDN.echartsJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/echarts/echarts.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/echarts/echarts.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.echartsMacaronsJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/echarts/macarons.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/echarts/macarons.js" "minify" true "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Mapbox GL */ -}}
|
||||
{{- if $scratch.Get "mapbox" -}}
|
||||
{{- with $CDN.mapboxGLCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/mapbox-gl/mapbox-gl.min.css" | $scratch.Add "linkLocal" -}}
|
||||
{{- dict "source" "lib/mapbox-gl/mapbox-gl.min.css" "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.mapboxGLJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/mapbox-gl/mapbox-gl.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/mapbox-gl/mapbox-gl.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- slice "lib/mapbox-gl/mapbox-gl-language.js" | $scratch.Add "scriptLocal" -}}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
mapboxgl.accessToken = '{{ .Params.mapbox.accessToken | default .Site.Params.mapbox.accessToken }}';
|
||||
mapboxgl.setRTLTextPlugin('https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.0/mapbox-gl-rtl-text.js');
|
||||
});
|
||||
</script>
|
||||
{{- dict "source" "lib/mapbox-gl/mapbox-gl-language.js" "minify" true "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- $mapbox := dict "accessToken" (.Params.mapbox.accessToken | default .Site.Params.mapbox.accessToken) "RTLTextPlugin" "https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.0/mapbox-gl-rtl-text.js" -}}
|
||||
{{- $config = dict "mapbox" $mapbox | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Music */ -}}
|
||||
{{- if $scratch.Get "music" -}}
|
||||
{{- /* APlayer */ -}}
|
||||
{{- with $CDN.aplayerCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/aplayer/APlayer.min.css" | $scratch.Add "linkLocal" -}}
|
||||
{{- dict "source" "lib/aplayer/APlayer.min.css" "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- slice "lib/aplayer/dark.scss" | $scratch.Add "linkLocal" -}}
|
||||
{{- $options := dict "targetPath" "lib/aplayer/dark.min.css" -}}
|
||||
{{- dict "source" "lib/aplayer/dark.scss" "toCSS" $options "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- with $CDN.aplayerJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/aplayer/APlayer.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/aplayer/APlayer.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* MetingJS */ -}}
|
||||
{{- with $CDN.metingJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/meting/Meting.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "lib/meting/Meting.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
@ -221,41 +243,20 @@
|
|||
{{- if .Params.dev -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $scratch.Get "contentMap" -}}
|
||||
<script>
|
||||
window.contentMap = {{ jsonify . | safeJS }};
|
||||
</script>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Theme script */ -}}
|
||||
{{- slice "js/theme.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- dict "source" "js/theme.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- $_ := (resources.Get "js/theme.min.js.map").RelPermalink -}}
|
||||
|
||||
{{- range $scratch.Get "linkCDN" -}}
|
||||
{{- safeHTML . -}}
|
||||
{{- end -}}
|
||||
{{- range $scratch.Get "linkLocal" -}}
|
||||
{{- $res := resources.Get . -}}
|
||||
{{- if strings.HasSuffix . ".scss" -}}
|
||||
{{- $options := dict "outputStyle" "compressed" "enableSourceMap" true -}}
|
||||
{{- $res = toCSS $options $res -}}
|
||||
{{- else if not (strings.HasSuffix . ".min.css") -}}
|
||||
{{- $res = minify $res -}}
|
||||
{{- end -}}
|
||||
{{- $stylesheet := dict "resource" $res "fingerprint" ($scratch.Get "fingerprint") -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
{{- range $scratch.Get "stylesheet" -}}
|
||||
{{- partial "plugin/stylesheet.html" . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- range $scratch.Get "scriptCDN" -}}
|
||||
{{- safeHTML . -}}
|
||||
{{- end -}}
|
||||
{{- range $scratch.Get "scriptLocal" -}}
|
||||
{{- $res := resources.Get . -}}
|
||||
{{- if not (strings.HasSuffix . ".min.js") -}}
|
||||
{{- $res = minify $res -}}
|
||||
{{- end -}}
|
||||
{{- $script := dict "resource" $res "fingerprint" ($scratch.Get "fingerprint") -}}
|
||||
{{- partial "plugin/script.html" $script -}}
|
||||
<script type="text/javascript">
|
||||
window.config = {{ jsonify $config | safeJS }};
|
||||
</script>
|
||||
|
||||
{{- range $scratch.Get "script" -}}
|
||||
{{- partial "plugin/script.html" . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Google analytics async */ -}}
|
||||
|
|
|
@ -1,126 +1,112 @@
|
|||
{{- $scratch := .Scratch.Get "scratch" -}}
|
||||
{{- $CDN := $scratch.Get "CDN" -}}
|
||||
{{- $fingerprint := $scratch.Get "fingerprint" -}}
|
||||
|
||||
{{- if eq hugo.Environment "production" | and (ne .Site.Params.comment.enable false) | and (ne .Params.comment false) -}}
|
||||
{{- $CDN := $scratch.Get "CDN" -}}
|
||||
|
||||
{{- /* Disqus Comment System */ -}}
|
||||
{{- if .Site.Params.comment.disqus.enable -}}
|
||||
<div id="disqus_thread" class="comment"></div>
|
||||
{{- $script := printf `<script defer src="https://%s.disqus.com/embed.js"></script>` .Site.Params.comment.disqus.shortname -}}
|
||||
{{- slice $script | $scratch.Add "scriptCDN" -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Gitalk Comment System */ -}}
|
||||
{{- if .Site.Params.comment.gitalk.enable -}}
|
||||
{{- $gitalk := .Site.Params.comment.gitalk -}}
|
||||
<div id="gitalk" class="comment"></div>
|
||||
{{- with $CDN.gitalkCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/gitalk/gitalk.css" | $scratch.Add "linkLocal" -}}
|
||||
<div id="comments">
|
||||
{{- /* Disqus Comment System */ -}}
|
||||
{{- if .Site.Params.comment.disqus.enable -}}
|
||||
<div id="disqus_thread" class="comment"></div>
|
||||
{{- $source := printf "https://%s.disqus.com/embed.js" .Site.Params.comment.disqus.shortname -}}
|
||||
{{- dict "source" $source "defer" true "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the comments powered by <a href="https://disqus.com/?ref_noscript">Disqus</a>.
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
{{- with $CDN.gitalkJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/gitalk/gitalk.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
|
||||
{{- /* Gitalk Comment System */ -}}
|
||||
{{- if .Site.Params.comment.gitalk.enable -}}
|
||||
{{- $gitalk := .Site.Params.comment.gitalk -}}
|
||||
<div id="gitalk" class="comment"></div>
|
||||
{{- with $CDN.gitalkCSS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- else -}}
|
||||
{{- dict "source" "lib/gitalk/gitalk.css" "minify" true "fingerprint" $fingerprint | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- end -}}
|
||||
{{- with $CDN.gitalkJS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- dict "source" "lib/gitalk/gitalk.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- $gitalkConfig := dict "id" .Date "title" .Title "clientID" $gitalk.clientId "clientSecret" $gitalk.clientSecret "repo" $gitalk.repo "owner" $gitalk.owner "admin" (slice $gitalk.owner) -}}
|
||||
{{- $scratch.SetInMap "comment" "gitalk" $gitalkConfig -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the comments powered by <a href="https://github.com/gitalk/gitalk"></a>Gitalk</a>.
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
var gitalk = new Gitalk({
|
||||
id: '{{ .Date }}',
|
||||
title: '{{ .Title }}',
|
||||
clientID: '{{ $gitalk.clientId }}',
|
||||
clientSecret: '{{ $gitalk.clientSecret }}',
|
||||
repo: '{{ $gitalk.repo }}',
|
||||
owner: '{{ $gitalk.owner }}',
|
||||
admin: ['{{ $gitalk.owner }}'],
|
||||
body: decodeURI(location.href),
|
||||
});
|
||||
gitalk.render('gitalk');
|
||||
});
|
||||
</script>
|
||||
<noscript>
|
||||
Please enable JavaScript to view the <a href="https://github.com/gitalk/gitalk">comments powered by Gitalk.</a>
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Valine Comment System */ -}}
|
||||
{{- if .Site.Params.comment.valine.enable -}}
|
||||
{{- $valine := .Site.Params.comment.valine -}}
|
||||
<div id="valine" class="comment"></div>
|
||||
{{- slice "lib/valine/valine.scss" | $scratch.Add "linkLocal" -}}
|
||||
{{- with $CDN.valineJS -}}
|
||||
{{- slice . | $scratch.Add "scriptCDN" -}}
|
||||
{{- else -}}
|
||||
{{- slice "lib/valine/Valine.min.js" | $scratch.Add "scriptLocal" -}}
|
||||
{{- /* Valine Comment System */ -}}
|
||||
{{- if .Site.Params.comment.valine.enable -}}
|
||||
{{- $valine := .Site.Params.comment.valine -}}
|
||||
<div id="valine" class="comment"></div>
|
||||
{{- $options := dict "targetPath" "lib/valine/valine.min.css" -}}
|
||||
{{- dict "source" "lib/valine/valine.scss" "toCSS" $options | slice | $scratch.Add "stylesheet" -}}
|
||||
{{- with $CDN.valineJS -}}
|
||||
{{- dict "source" . "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
{{- else -}}
|
||||
{{- dict "source" "lib/valine/Valine.min.js" "fingerprint" $fingerprint | slice | $scratch.Add "script" -}}
|
||||
{{- end -}}
|
||||
{{- $valineConfig := dict "el" "#valine" "appId" $valine.appId "appKey" $valine.appKey "lang" ($valine.lang | default "en") "notify" $valine.notify "verify" $valine.verify "visitor" $valine.visitor "recordIP" $valine.recordIP -}}
|
||||
{{- with $valine.placeholder -}}
|
||||
{{- $valineConfig = dict "placeholder" . | merge $valineConfig -}}
|
||||
{{- end -}}
|
||||
{{- with $valine.avatar -}}
|
||||
{{- $valineConfig = dict "avatar" . | merge $valineConfig -}}
|
||||
{{- end -}}
|
||||
{{- with $valine.meta -}}
|
||||
{{- $valineConfig = dict "meta" . | merge $valineConfig -}}
|
||||
{{- end -}}
|
||||
{{- with $valine.pageSize -}}
|
||||
{{- $valineConfig = dict "pageSize" . | merge $valineConfig -}}
|
||||
{{- end -}}
|
||||
{{- $scratch.SetInMap "comment" "valine" $valineConfig -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the comments powered by <a href="https://valine.js.org/">Valine</a>.
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
new Valine({
|
||||
el: '#valine',
|
||||
appId: '{{ $valine.appId }}',
|
||||
appKey: '{{ $valine.appKey }}',
|
||||
{{- with $valine.placeholder -}}
|
||||
placeholder: '{{ . }}',
|
||||
{{- end -}}
|
||||
{{- if $valine.notify -}}
|
||||
notify: true,
|
||||
{{- end -}}
|
||||
{{- if $valine.verify -}}
|
||||
verify: true,
|
||||
{{- end -}}
|
||||
{{- with $valine.avatar -}}
|
||||
avatar: '{{ . }}',
|
||||
{{- end -}}
|
||||
{{- with $valine.meta -}}
|
||||
meta: {{ . | safeJS }},
|
||||
{{- end -}}
|
||||
{{- with $valine.pageSize -}}
|
||||
pageSize: {{ . | safeJS }},
|
||||
{{- end -}}
|
||||
lang: '{{ $valine.lang | default "en" }}',
|
||||
{{- if $valine.visitor -}}
|
||||
visitor: true,
|
||||
{{- end -}}
|
||||
{{- if $valine.recordIP -}}
|
||||
recordIP: true,
|
||||
{{- end -}}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<noscript>
|
||||
Please enable JavaScript to view the <a href="https://valine.js.org/">comments powered by Valine.</a>
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Facebook Comment System */ -}}
|
||||
{{- if .Site.Params.comment.facebook.enable -}}
|
||||
{{- $facebook := .Site.Params.comment.facebook -}}
|
||||
<div id="fb-root" class="comment"></div>
|
||||
<div
|
||||
class="fb-comments"
|
||||
data-href="{{ .Site.Params.baseURL }}{{ .Permalink | absURL }}"
|
||||
data-width="{{ $facebook.width }}"
|
||||
data-numposts="{{ $facebook.numPosts }}"
|
||||
></div>
|
||||
{{- $script := `<script src="https://connect.facebook.net/%s/sdk.js#xfbml=1&version=v5.0&appId=%s&autoLogAppEvents=1" crossorigin="anonymous"></script>` -}}
|
||||
{{- $script = printf $script $facebook.languageCode $facebook.appId -}}
|
||||
{{- slice $script | $scratch.Add "scriptCDN" -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the <a href="https://developers.facebook.com/docs/plugins/comments/">comments powered by Facebook.</a>
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
{{- /* Facebook Comment System */ -}}
|
||||
{{- if .Site.Params.comment.facebook.enable -}}
|
||||
{{- $facebook := .Site.Params.comment.facebook -}}
|
||||
<div id="fb-root" class="comment"></div>
|
||||
<div
|
||||
class="fb-comments"
|
||||
data-href="{{ .Site.Params.baseURL }}{{ .Permalink | absURL }}"
|
||||
data-width="{{ $facebook.width }}"
|
||||
data-numposts="{{ $facebook.numPosts }}"
|
||||
></div>
|
||||
{{- $source := printf "https://connect.facebook.net/%s/sdk.js#xfbml=1&version=v5.0&appId=%s&autoLogAppEvents=1" $facebook.languageCode $facebook.appId -}}
|
||||
{{- dict "source" $source "defer" true "crossorigin" true | slice | $scratch.Add "script" -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the comments powered by <a href="https://developers.facebook.com/docs/plugins/comments/"></a>Facebook</a>.
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Telegram Comments System */ -}}
|
||||
{{- if .Site.Params.comment.telegram.enable -}}
|
||||
{{- $telegram := .Site.Params.comment.telegram -}}
|
||||
<div id="telegram-comments" class="comment"></div>
|
||||
<script async src="https://comments.app/js/widget.js?2" data-comments-app-website="{{ $telegram.siteID }}" data-limit="{{ $telegram.limit | default 5 }}"{{ with $telegram.height }} data-height="{{ . }}"{{ end }}{{ with $telegram.color }} data-color="{{ . }}"{{ end }}{{ if $telegram.colorful }} data-colorful="1"{{ end }}{{ if $telegram.dislikes }} data-dislikes="1"{{ end }}{{ if $telegram.outlined }} data-outlined="1"{{ end }}></script>
|
||||
<noscript>
|
||||
Please enable JavaScript to view the <a href="https://comments.app/">comments powered by Telegram Comments.</a>
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
{{- /* Telegram Comments System */ -}}
|
||||
{{- if .Site.Params.comment.telegram.enable -}}
|
||||
{{- $telegram := .Site.Params.comment.telegram -}}
|
||||
<div id="telegram-comments" class="comment"></div>
|
||||
{{- $attr := printf `data-comments-app-website="%s"` $telegram.siteID -}}
|
||||
{{- $attr = printf `%s data-limit="%s"` $attr ($telegram.limit | default 5) -}}
|
||||
{{- with $telegram.height -}}
|
||||
{{- $attr = printf `%s data-height="%s"` $attr . -}}
|
||||
{{- end -}}
|
||||
{{- with $telegram.color -}}
|
||||
{{- $attr = printf `%s data-color="%s"` $attr . -}}
|
||||
{{- end -}}
|
||||
{{- if $telegram.colorful -}}
|
||||
{{- $attr = printf `%s data-colorful="1"` $attr -}}
|
||||
{{- end -}}
|
||||
{{- if $telegram.dislikes -}}
|
||||
{{- $attr = printf `%s data-dislikes="1"` $attr -}}
|
||||
{{- end -}}
|
||||
{{- if $telegram.outlined -}}
|
||||
{{- $attr = printf `%s data-outlined="1"` $attr -}}
|
||||
{{- end -}}
|
||||
{{- dict "source" "https://comments.app/js/widget.js?2" "defer" true "crossorigin" true "attr" $attr | slice | $scratch.Add "script" -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the comments powered by <a href="https://comments.app/">Telegram Comments</a>.
|
||||
</noscript>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
|
|
@ -10,4 +10,4 @@
|
|||
|
||||
{{- $content = partial "function/escape.html" $content -}}
|
||||
|
||||
{{- $content | safeHTML -}}
|
||||
{{- return $content -}}
|
|
@ -3,6 +3,6 @@
|
|||
{{- /* shuffle md5 as id */ -}}
|
||||
{{- $id := delimit (split (md5 now.Unix) "" | shuffle | first 6) "" | printf "id-%s" -}}
|
||||
{{- with .scratch -}}
|
||||
{{- .SetInMap "contentMap" $id $.content -}}
|
||||
{{- .SetInMap "contentData" $id $.content -}}
|
||||
{{- end -}}
|
||||
{{- return $id -}}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{{- $scratch := .Scratch.Get "scratch" -}}
|
||||
{{- $CDN := $scratch.Get "CDN" -}}
|
||||
{{- $fingerprint := $scratch.Get "fingerprint" -}}
|
||||
|
||||
<link rel="canonical" href="{{ .Permalink }}" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
|
@ -22,29 +23,17 @@
|
|||
{{- end -}}
|
||||
|
||||
{{- /* Font Awesome */ -}}
|
||||
{{- with $CDN.fontawesomeFreeCSS -}}
|
||||
{{- . | safeHTML -}}
|
||||
{{- else -}}
|
||||
{{- $res := resources.Get "lib/fontawesome-free/all.min.css" -}}
|
||||
{{- $stylesheet := dict "resource" $res "fingerprint" ($scratch.Get "fingerprint") -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
{{- end -}}
|
||||
{{- $source := $CDN.fontawesomeFreeCSS | default "lib/fontawesome-free/all.min.css" -}}
|
||||
{{- $stylesheet := dict "source" $source "fingerprint" $fingerprint -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
|
||||
{{- /* Animate.css */ -}}
|
||||
{{- with $CDN.animateCSS -}}
|
||||
{{- . | safeHTML -}}
|
||||
{{- else -}}
|
||||
{{- $res := resources.Get "lib/animate/animate.min.css" -}}
|
||||
{{- $stylesheet := dict "resource" $res "fingerprint" ($scratch.Get "fingerprint") -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
{{- end -}}
|
||||
{{- $source := $CDN.animateCSS | default "lib/animate/animate.min.css" -}}
|
||||
{{- $stylesheet := dict "source" $source "fingerprint" $fingerprint -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
|
||||
{{- /* style.min.css */ -}}
|
||||
{{- $res := resources.Get "css/style.template.scss" -}}
|
||||
{{- $options := dict "targetPath" "css/style.min.css" -}}
|
||||
{{- $options = dict "includePaths" (slice "config/css") | merge $options -}}
|
||||
{{- $options = dict "outputStyle" "compressed" | merge $options -}}
|
||||
{{- $options = dict "enableSourceMap" true | merge $options -}}
|
||||
{{- $res = resources.ExecuteAsTemplate "style.scss" . $res | toCSS $options -}}
|
||||
{{- $stylesheet := dict "resource" $res "fingerprint" ($scratch.Get "fingerprint") -}}
|
||||
{{- $stylesheet := dict "source" "css/style.template.scss" "fingerprint" $fingerprint -}}
|
||||
{{- $options := dict "targetPath" "css/style.min.css" "includePaths" (slice "config/css") -}}
|
||||
{{- $stylesheet = dict "template" "style.scss" "context" . "toCSS" $options | merge $stylesheet -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
|
|
|
@ -7,43 +7,59 @@
|
|||
</a>
|
||||
</div>
|
||||
<div class="menu">
|
||||
{{- range .Site.Menus.main -}}
|
||||
<a class="menu-item{{ if $.IsMenuCurrent "main" . | or ($.HasMenuCurrent "main" .) | or (.URL | relLangURL | string | eq $.RelPermalink ) }} active{{ end }}" href="{{ .URL | relLangURL }}"{{ with .Title }} title="{{ . }}"{{ end }} rel="noopener noreffer"{{ if strings.HasPrefix .URL "http" }} target="_blank"{{ end }}>
|
||||
{{- .Pre | safeHTML }}{{ .Name -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
<span class="menu-item">|</span>
|
||||
<a href="javascript:void(0);" class="menu-item theme-switch" title="{{ T "switchTheme" }}">
|
||||
<i class="fas fa-adjust fa-fw"></i>
|
||||
</a>
|
||||
{{- if .Site.IsMultiLingual -}}
|
||||
<a href="javascript:void(0);" class="menu-item" title="{{ T "selectLanguage" }}">
|
||||
{{- .Language.LanguageName -}}
|
||||
<i class="fas fa-chevron-right fa-fw"></i>
|
||||
<select class="language-select" id="language-select-desktop" onchange="location = this.value;">
|
||||
{{- range .Page.AllTranslations -}}
|
||||
{{- $translation := . -}}
|
||||
{{- range $.Site.Languages -}}
|
||||
{{- if eq $translation.Lang .Lang -}}
|
||||
{{- if eq $.Page.Lang .Lang -}}
|
||||
<option value="{{ $translation.RelPermalink }}" selected>{{ .LanguageName }}</option>
|
||||
{{- else -}}
|
||||
<option value="{{ $translation.RelPermalink }}">{{ .LanguageName }}</option>
|
||||
<div class="menu-inner">
|
||||
{{- range .Site.Menus.main -}}
|
||||
<a class="menu-item{{ if $.IsMenuCurrent "main" . | or ($.HasMenuCurrent "main" .) | or (.URL | relLangURL | string | eq $.RelPermalink ) }} active{{ end }}" href="{{ .URL | relLangURL }}"{{ with .Title }} title="{{ . }}"{{ end }} rel="noopener noreffer"{{ if strings.HasPrefix .URL "http" }} target="_blank"{{ end }}>
|
||||
{{- .Pre | safeHTML }}{{ .Name -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
<span class="menu-item delimiter"></span>
|
||||
{{- if .Site.IsMultiLingual -}}
|
||||
<a href="javascript:void(0);" class="menu-item language" title="{{ T "selectLanguage" }}">
|
||||
{{- .Language.LanguageName -}}
|
||||
<i class="fas fa-chevron-right fa-fw"></i>
|
||||
<select class="language-select" id="language-select-desktop" onchange="location = this.value;">
|
||||
{{- range .Page.AllTranslations -}}
|
||||
{{- $translation := . -}}
|
||||
{{- range $.Site.Languages -}}
|
||||
{{- if eq $translation.Lang .Lang -}}
|
||||
{{- if eq $.Page.Lang .Lang -}}
|
||||
<option value="{{ $translation.RelPermalink }}" selected>{{ .LanguageName }}</option>
|
||||
{{- else -}}
|
||||
<option value="{{ $translation.RelPermalink }}">{{ .LanguageName }}</option>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</select>
|
||||
</select>
|
||||
</a>
|
||||
{{- end -}}
|
||||
{{- if .Site.Params.search.enable -}}
|
||||
<span class="menu-item search" id="search-desktop">
|
||||
<input type="text" placeholder="{{ T `searchPlaceholder` }}" id="search-input-desktop">
|
||||
<a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-desktop" title="{{ T `search` }}">
|
||||
<i class="fas fa-search fa-fw"></i>
|
||||
</a>
|
||||
<a href="javascript:void(0);" class="search-button search-clear" id="search-clear-desktop" title="{{ T `clear` }}">
|
||||
<i class="fas fa-times-circle fa-fw"></i>
|
||||
</a>
|
||||
<span class="search-button search-loading" id="search-loading-desktop">
|
||||
<i class="fas fa-spinner fa-fw fa-spin"></i>
|
||||
</span>
|
||||
</span>
|
||||
{{- end -}}
|
||||
<a href="javascript:void(0);" class="menu-item theme-switch" title="{{ T "switchTheme" }}">
|
||||
<i class="fas fa-adjust fa-fw"></i>
|
||||
</a>
|
||||
{{- end -}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{{- /* Mobile header */ -}}
|
||||
<header class="mobile" id="header-mobile">
|
||||
<div class="header-wrapper">
|
||||
<div class="header-container">
|
||||
<div class="header-container">
|
||||
<div class="header-wrapper">
|
||||
<div class="header-title">
|
||||
<a href="{{ `/` | relLangURL }}">
|
||||
{{- .Site.Title -}}
|
||||
|
@ -54,6 +70,25 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="menu" id="menu-mobile">
|
||||
{{- if .Site.Params.search.enable -}}
|
||||
<div class="search-wrapper">
|
||||
<div class="search mobile" id="search-mobile">
|
||||
<input type="text" placeholder="{{ T `searchPlaceholder` }}" id="search-input-mobile">
|
||||
<a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-mobile" title="{{ T `search` }}">
|
||||
<i class="fas fa-search fa-fw"></i>
|
||||
</a>
|
||||
<a href="javascript:void(0);" class="search-button search-clear" id="search-clear-mobile" title="{{ T `clear` }}">
|
||||
<i class="fas fa-times-circle fa-fw"></i>
|
||||
</a>
|
||||
<span class="search-button search-loading" id="search-loading-mobile">
|
||||
<i class="fas fa-spinner fa-fw fa-spin"></i>
|
||||
</span>
|
||||
</div>
|
||||
<a href="javascript:void(0);" class="search-cancel" id="search-cancel-mobile">
|
||||
{{ T `cancel` }}
|
||||
</a>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- $currentPage := . -}}
|
||||
{{- range .Site.Menus.main -}}
|
||||
<a class="menu-item" href="{{ .URL | relLangURL }}" title="{{ .Title }}" rel="noopener noreffer"{{ if strings.HasPrefix .URL "http" }} target="_blank"{{ end }}>
|
||||
|
@ -86,8 +121,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<script>
|
||||
window.desktopHeaderMode = {{ .Site.Params.header.desktopMode }};
|
||||
window.mobileHeaderMode = {{ .Site.Params.header.mobileMode }};
|
||||
</script>
|
||||
<div class="search-dropdown desktop">
|
||||
<div id="search-dropdown-desktop"></div>
|
||||
</div>
|
||||
<div class="search-dropdown mobile">
|
||||
<div id="search-dropdown-mobile"></div>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,21 @@
|
|||
{{- $res := .resource -}}
|
||||
{{- with .fingerprint -}}
|
||||
{{- $res = $res | resources.Fingerprint . -}}
|
||||
<script src="{{ $res.RelPermalink }}" integrity="{{ $res.Data.Integrity }}"></script>
|
||||
{{- if strings.HasPrefix .source "<script" -}}
|
||||
{{- safeHTML .source -}}
|
||||
{{- else -}}
|
||||
<script src="{{ $res.RelPermalink }}"></script>
|
||||
{{- $src := .source -}}
|
||||
{{- $integrity := .integrity -}}
|
||||
{{- if strings.HasPrefix $src "http" | not -}}
|
||||
{{- $res := resources.Get $src -}}
|
||||
{{- with .template -}}
|
||||
{{- $res = $res | resources.ExecuteAsTemplate . $.context -}}
|
||||
{{- end -}}
|
||||
{{- if .minify -}}
|
||||
{{- $res = $res | minify -}}
|
||||
{{- end -}}
|
||||
{{- with .fingerprint -}}
|
||||
{{- $res = $res | fingerprint . -}}
|
||||
{{- $integrity = $res.Data.Integrity -}}
|
||||
{{- end -}}
|
||||
{{- $src = $res.RelPermalink -}}
|
||||
{{- end -}}
|
||||
<script type="text/javascript" src="{{ $src }}"{{ if .crossorigin }} crossorigin="anonymous"{{ end }}{{ with $integrity }} integrity="{{ . }}"{{ end }}{{ if .async }} async{{ end }}{{ if .defer }} defer{{ end }}{{ with .attr }} {{ . | safeHTMLAttr }}{{ end }}></script>
|
||||
{{- end -}}
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
{{- $res := .resource -}}
|
||||
{{- with .fingerprint -}}
|
||||
{{- $res = $res | resources.Fingerprint . -}}
|
||||
<link rel="stylesheet" href="{{ $res.RelPermalink }}" integrity="{{ $res.Data.Integrity }}">
|
||||
{{- if strings.HasPrefix .source "<link" -}}
|
||||
{{- safeHTML .source -}}
|
||||
{{- else -}}
|
||||
<link rel="stylesheet" href="{{ $res.RelPermalink }}">
|
||||
{{- $href := .source -}}
|
||||
{{- $integrity := .integrity -}}
|
||||
{{- if strings.HasPrefix $href "http" | not -}}
|
||||
{{- $res := resources.Get $href -}}
|
||||
{{- with .template -}}
|
||||
{{- $res = $res | resources.ExecuteAsTemplate . $.context -}}
|
||||
{{- end -}}
|
||||
{{- with .toCSS -}}
|
||||
{{- $options := . | merge (dict "outputStyle" "compressed" "enableSourceMap" true) -}}
|
||||
{{- $res = $res | toCSS $options -}}
|
||||
{{- end -}}
|
||||
{{- if .minify -}}
|
||||
{{- $res = $res | minify -}}
|
||||
{{- end -}}
|
||||
{{- with .fingerprint -}}
|
||||
{{- $res = $res | fingerprint . -}}
|
||||
{{- $integrity = $res.Data.Integrity -}}
|
||||
{{- end -}}
|
||||
{{- $href = $res.RelPermalink -}}
|
||||
{{- end -}}
|
||||
<link rel="stylesheet" href="{{ $href }}"{{ if .crossorigin }} crossorigin="anonymous"{{ end }}{{ with $integrity }} integrity="{{ . }}"{{ end }}{{ with .attr }} {{ . | safeHTMLAttr }}{{ end }}>
|
||||
{{- end -}}
|
||||
|
|
|
@ -2,6 +2,16 @@
|
|||
|
||||
{{- define "content" -}}
|
||||
{{- $scratch := .Scratch.Get "scratch" -}}
|
||||
|
||||
{{- /* Auto TOC */ -}}
|
||||
{{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
|
||||
<div class="toc" id="toc-auto">
|
||||
<h2 class="toc-title">{{ T "contents" }}</h2>
|
||||
{{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }}
|
||||
<div class="toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}" id="toc-content-auto"></div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
<article class="page single">
|
||||
{{- /* Title */ -}}
|
||||
<h1 class="single-title animated flipInX">{{ .Title }}</h1>
|
||||
|
@ -52,13 +62,8 @@
|
|||
</div>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* TOC */ -}}
|
||||
{{- /* Static TOC */ -}}
|
||||
{{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
|
||||
<div class="toc" id="toc-auto">
|
||||
<h2 class="toc-title">{{ T "contents" }}</h2>
|
||||
{{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }}
|
||||
<div class="toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}" id="toc-content-auto"></div>
|
||||
</div>
|
||||
<div class="toc" id="toc-static">
|
||||
<details>
|
||||
<summary>
|
||||
|
@ -79,7 +84,7 @@
|
|||
|
||||
{{- /* Content */ -}}
|
||||
<div class="content" id="content">
|
||||
{{- partial "single/content.html" .Content -}}
|
||||
{{- partial "function/content.html" .Content | safeHTML -}}
|
||||
</div>
|
||||
|
||||
{{- /* Footer */ -}}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
{{- $darkStyle = .Get 5 | default $darkStyle -}}
|
||||
{{- end -}}
|
||||
{{- $darkStyle = $darkStyle | default $lightStyle -}}
|
||||
{{- $options := dict "lng" $lng "lat" $lat "zoom" $zoom "marked" $marked "light-style" $lightStyle "dark-style" $darkStyle "geolocate" $geolocate "navigation" $navigation "scale" $scale "fullscreen" $fullscreen -}}
|
||||
{{- $options := dict "lng" $lng "lat" $lat "zoom" $zoom "marked" $marked "lightStyle" $lightStyle "darkStyle" $darkStyle "geolocate" $geolocate "navigation" $navigation "scale" $scale "fullscreen" $fullscreen -}}
|
||||
{{- $id := partial "function/id.html" (dict "content" $options "scratch" $scratch) -}}
|
||||
<div class="mapbox" id="{{ $id }}" style="width: {{ $width }}; height: {{ $height }};"></div>
|
||||
{{- $scratch.Set "mapbox" true -}}
|
||||
|
|
1719
package-lock.json
generated
1719
package-lock.json
generated
File diff suppressed because it is too large
Load diff
24
package.json
24
package.json
|
@ -2,22 +2,32 @@
|
|||
"name": "loveit-src",
|
||||
"version": "0.2.0",
|
||||
"description": "LoveIt theme source file",
|
||||
"main": "index.js",
|
||||
"private": true,
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.8.4",
|
||||
"@babel/core": "^7.8.4",
|
||||
"@babel/preset-env": "^7.8.4",
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/preset-env": "^7.9.0",
|
||||
"babel-preset-minify": "^0.5.1",
|
||||
"minimist": ">=1.2.2",
|
||||
"husky": "^4.2.3"
|
||||
"babelify": "^10.0.0",
|
||||
"browserify": "^16.5.0",
|
||||
"core-js": "^3.6.4",
|
||||
"husky": "^4.2.3",
|
||||
"minimist": "^1.2.5",
|
||||
"segmentit": "^2.0.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npx babel src --out-file assets/js/theme.min.js --source-maps && hugo -v --source=exampleSite --themesDir=../.. -D --gc",
|
||||
"start": "npm run build && hugo server --source=exampleSite --themesDir=../.. --disableFastRender",
|
||||
"preinstall": "npx npm-force-resolutions",
|
||||
"babel": "npx babel src/js --out-file assets/js/theme.min.js --source-maps",
|
||||
"build": "npm run babel && hugo -v --source=exampleSite --themesDir=../.. -D --gc",
|
||||
"build-lunr-segmentit": "browserify src/lib/lunr.segmentit.js -o assets/lib/lunr/lunr.segmentit.js -t babelify --presets @babel/preset-env --presets minify",
|
||||
"start": "npm run babel && hugo server --source=exampleSite --themesDir=../.. --disableFastRender",
|
||||
"check": "htmlproofer exampleSite/public --check-html --allow-hash-href --empty-alt-ignore --disable-external",
|
||||
"copy": "rm -rf resources && cp -rf exampleSite/resources resources"
|
||||
},
|
||||
"resolutions": {
|
||||
"minimist": "^1.2.5"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run build && npm run copy && git add .",
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,3 +0,0 @@
|
|||
.dark-theme .aplayer{background:#212121}.dark-theme .aplayer.aplayer-withlist .aplayer-info{border-bottom-color:#5c5c5c}.dark-theme .aplayer.aplayer-fixed .aplayer-list{border-color:#5c5c5c}.dark-theme .aplayer .aplayer-body{background-color:#212121}.dark-theme .aplayer .aplayer-info{border-top-color:#212121}.dark-theme .aplayer .aplayer-info .aplayer-music .aplayer-title{color:#fff}.dark-theme .aplayer .aplayer-info .aplayer-music .aplayer-author{color:#fff}.dark-theme .aplayer .aplayer-info .aplayer-controller .aplayer-time{color:#eee}.dark-theme .aplayer .aplayer-info .aplayer-controller .aplayer-time .aplayer-icon path{fill:#eee}.dark-theme .aplayer .aplayer-list{background-color:#212121}.dark-theme .aplayer .aplayer-list::-webkit-scrollbar-thumb{background-color:#999}.dark-theme .aplayer .aplayer-list::-webkit-scrollbar-thumb:hover{background-color:#bbb}.dark-theme .aplayer .aplayer-list li{color:#fff;border-top-color:#666}.dark-theme .aplayer .aplayer-list li:hover{background:#4e4e4e}.dark-theme .aplayer .aplayer-list li.aplayer-list-light{background:#6c6c6c}.dark-theme .aplayer .aplayer-list li .aplayer-list-index{color:#ddd}.dark-theme .aplayer .aplayer-list li .aplayer-list-author{color:#ddd}.dark-theme .aplayer .aplayer-lrc{text-shadow:-1px -1px 0 #666}.dark-theme .aplayer .aplayer-lrc:before{background:-moz-linear-gradient(top, #212121 0%, rgba(33,33,33,0) 100%);background:-webkit-linear-gradient(top, #212121 0%, rgba(33,33,33,0) 100%);background:linear-gradient(to bottom, #212121 0%, rgba(33,33,33,0) 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#212121', endColorstr='#00212121',GradientType=0 )}.dark-theme .aplayer .aplayer-lrc:after{background:-moz-linear-gradient(top, rgba(33,33,33,0) 0%, rgba(33,33,33,0.8) 100%);background:-webkit-linear-gradient(top, rgba(33,33,33,0) 0%, rgba(33,33,33,0.8) 100%);background:linear-gradient(to bottom, rgba(33,33,33,0) 0%, rgba(33,33,33,0.8) 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#00212121', endColorstr='#cc212121',GradientType=0 )}.dark-theme .aplayer .aplayer-lrc p{color:#fff}.dark-theme .aplayer .aplayer-miniswitcher{background:#484848}.dark-theme .aplayer .aplayer-miniswitcher .aplayer-icon path{fill:#eee}
|
||||
|
||||
/*# sourceMappingURL=dark.css.map */
|
|
@ -1 +0,0 @@
|
|||
{"Target":"lib/aplayer/dark.css","MediaType":"text/css","Data":{}}
|
|
@ -0,0 +1,3 @@
|
|||
.dark .aplayer{background:#212121}.dark .aplayer.aplayer-withlist .aplayer-info{border-bottom-color:#5c5c5c}.dark .aplayer.aplayer-fixed .aplayer-list{border-color:#5c5c5c}.dark .aplayer .aplayer-body{background-color:#212121}.dark .aplayer .aplayer-info{border-top-color:#212121}.dark .aplayer .aplayer-info .aplayer-music .aplayer-title{color:#fff}.dark .aplayer .aplayer-info .aplayer-music .aplayer-author{color:#fff}.dark .aplayer .aplayer-info .aplayer-controller .aplayer-time{color:#eee}.dark .aplayer .aplayer-info .aplayer-controller .aplayer-time .aplayer-icon path{fill:#eee}.dark .aplayer .aplayer-list{background-color:#212121}.dark .aplayer .aplayer-list::-webkit-scrollbar-thumb{background-color:#999}.dark .aplayer .aplayer-list::-webkit-scrollbar-thumb:hover{background-color:#bbb}.dark .aplayer .aplayer-list li{color:#fff;border-top-color:#666}.dark .aplayer .aplayer-list li:hover{background:#4e4e4e}.dark .aplayer .aplayer-list li.aplayer-list-light{background:#6c6c6c}.dark .aplayer .aplayer-list li .aplayer-list-index{color:#ddd}.dark .aplayer .aplayer-list li .aplayer-list-author{color:#ddd}.dark .aplayer .aplayer-lrc{text-shadow:-1px -1px 0 #666}.dark .aplayer .aplayer-lrc:before{background:-moz-linear-gradient(top, #212121 0%, rgba(33,33,33,0) 100%);background:-webkit-linear-gradient(top, #212121 0%, rgba(33,33,33,0) 100%);background:linear-gradient(to bottom, #212121 0%, rgba(33,33,33,0) 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#212121', endColorstr='#00212121',GradientType=0 )}.dark .aplayer .aplayer-lrc:after{background:-moz-linear-gradient(top, rgba(33,33,33,0) 0%, rgba(33,33,33,0.8) 100%);background:-webkit-linear-gradient(top, rgba(33,33,33,0) 0%, rgba(33,33,33,0.8) 100%);background:linear-gradient(to bottom, rgba(33,33,33,0) 0%, rgba(33,33,33,0.8) 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#00212121', endColorstr='#cc212121',GradientType=0 )}.dark .aplayer .aplayer-lrc p{color:#fff}.dark .aplayer .aplayer-miniswitcher{background:#484848}.dark .aplayer .aplayer-miniswitcher .aplayer-icon path{fill:#eee}
|
||||
|
||||
/*# sourceMappingURL=dark.min.css.map */
|
|
@ -0,0 +1 @@
|
|||
{"Target":"lib/aplayer/dark.min.css","MediaType":"text/css","Data":{}}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
{"Target":"lib/mermaid/mermaid.min.css","MediaType":"text/css","Data":{}}
|
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
{"Target":"lib/mermaid/mermaid.css","MediaType":"text/css","Data":{}}
|
|
@ -1,3 +0,0 @@
|
|||
.dark-theme .v *,.dark-theme .v .vwrap .vheader .vinput,.dark-theme .v .vlist .vcard .vh,.dark-theme .v .vlist .vcard .vquote{border-color:#4a4b50}.dark-theme .v blockquote{border-left:.25rem solid #00bfa5}.dark-theme .v *,.dark-theme .v .vwrap input,.dark-theme .v .vwrap input::placeholder,.dark-theme .v .veditor,.dark-theme .v .veditor::placeholder,.dark-theme .v a,.dark-theme .v a:hover{color:#a9a9b3}.dark-theme .v .vbtn{color:#a9a9b3;background:#222325;border-color:#292a2d}.dark-theme .v .vbtn:hover{color:#55bde2;border-color:#55bde2}.dark-theme .v .vlist .vcard .vhead .vsys{background:#20252b}.dark-theme .v code,.dark-theme .v pre{background:#272C34}.dark-theme .v .vmark .vinput{color:#222325}.v blockquote{border-left:.25rem solid #00bfa5}.v code,.v pre{text-align:left}
|
||||
|
||||
/*# sourceMappingURL=valine.css.map */
|
|
@ -1 +0,0 @@
|
|||
{"Target":"lib/valine/valine.css","MediaType":"text/css","Data":{}}
|
|
@ -0,0 +1,3 @@
|
|||
.dark .v *,.dark .v .vwrap .vheader .vinput,.dark .v .vlist .vcard .vh,.dark .v .vlist .vcard .vquote{border-color:#4a4b50}.dark .v blockquote{border-left:.25rem solid #00bfa5}.dark .v *,.dark .v .vwrap input,.dark .v .vwrap input::placeholder,.dark .v .veditor,.dark .v .veditor::placeholder,.dark .v a,.dark .v a:hover{color:#a9a9b3}.dark .v .vbtn{color:#a9a9b3;background:#222325;border-color:#292a2d}.dark .v .vbtn:hover{color:#55bde2;border-color:#55bde2}.dark .v .vlist .vcard .vhead .vsys{background:#20252b}.dark .v code,.dark .v pre{background:#272C34}.dark .v .vmark .vinput{color:#222325}.v blockquote{border-left:.25rem solid #00bfa5}.v code,.v pre{text-align:left}
|
||||
|
||||
/*# sourceMappingURL=valine.min.css.map */
|
|
@ -0,0 +1 @@
|
|||
{"Target":"lib/valine/valine.min.css","MediaType":"text/css","Data":{}}
|
891
src/js/theme.js
891
src/js/theme.js
|
@ -1,234 +1,445 @@
|
|||
(() => {
|
||||
'use strict';
|
||||
|
||||
class Util {
|
||||
forEach(elements, handler) {
|
||||
elements = elements || [];
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
handler(elements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
getScrollTop() {
|
||||
return (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
|
||||
}
|
||||
|
||||
isMobile() {
|
||||
return window.matchMedia('only screen and (max-width: 680px)').matches;
|
||||
}
|
||||
|
||||
isTocStatic() {
|
||||
return window.matchMedia('only screen and (max-width: 960px)').matches;
|
||||
class Util {
|
||||
forEach(elements, handler) {
|
||||
elements = elements || [];
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
handler(elements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
class Theme {
|
||||
constructor() {
|
||||
this.util = new Util();
|
||||
this.newScrollTop = this.util.getScrollTop();
|
||||
this.oldScrollTop = this.newScrollTop;
|
||||
this.scrollEventSet = new Set();
|
||||
this.resizeEventSet = new Set();
|
||||
this.switchThemeEventSet = new Set();
|
||||
}
|
||||
getScrollTop() {
|
||||
return (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
|
||||
}
|
||||
|
||||
initMenuMobile() {
|
||||
const menuToggleMobile = document.getElementById('menu-toggle-mobile');
|
||||
const menuMobile = document.getElementById('menu-mobile');
|
||||
this._menuMobileOnScroll = this._menuMobileOnScroll || (() => {
|
||||
menuToggleMobile.classList.remove('active');
|
||||
menuMobile.classList.remove('active');
|
||||
isMobile() {
|
||||
return window.matchMedia('only screen and (max-width: 680px)').matches;
|
||||
}
|
||||
|
||||
isTocStatic() {
|
||||
return window.matchMedia('only screen and (max-width: 960px)').matches;
|
||||
}
|
||||
}
|
||||
|
||||
class Theme {
|
||||
constructor() {
|
||||
this.config = window.config;
|
||||
this.contentData = this.config.content;
|
||||
this.isDark = document.body.classList.contains('dark');
|
||||
this.util = new Util();
|
||||
this.newScrollTop = this.util.getScrollTop();
|
||||
this.oldScrollTop = this.newScrollTop;
|
||||
this.scrollEventSet = new Set();
|
||||
this.resizeEventSet = new Set();
|
||||
this.switchThemeEventSet = new Set();
|
||||
this.clickMaskEventSet = new Set();
|
||||
}
|
||||
|
||||
initMenuMobile() {
|
||||
const $menuToggleMobile = document.getElementById('menu-toggle-mobile');
|
||||
const $menuMobile = document.getElementById('menu-mobile');
|
||||
$menuToggleMobile.addEventListener('click', () => {
|
||||
document.body.classList.toggle('blur');
|
||||
$menuToggleMobile.classList.toggle('active');
|
||||
$menuMobile.classList.toggle('active');
|
||||
}, false);
|
||||
this._menuMobileOnClickMask = this._menuMobileOnClickMask || (() => {
|
||||
$menuToggleMobile.classList.remove('active');
|
||||
$menuMobile.classList.remove('active');
|
||||
});
|
||||
this.clickMaskEventSet.add(this._menuMobileOnClickMask);
|
||||
}
|
||||
|
||||
initSwitchTheme() {
|
||||
this.util.forEach(document.getElementsByClassName('theme-switch'), $themeSwitch => {
|
||||
$themeSwitch.addEventListener('click', () => {
|
||||
document.body.classList.toggle('dark');
|
||||
this.isDark = !this.isDark;
|
||||
window.localStorage && localStorage.setItem('theme', this.isDark ? 'dark' : 'light');
|
||||
for (let event of this.switchThemeEventSet) event();
|
||||
}, false);
|
||||
});
|
||||
}
|
||||
|
||||
initSearch() {
|
||||
const searchConfig = this.config.search;
|
||||
const isMobile = this.util.isMobile();
|
||||
if (!searchConfig || isMobile && this._searchMobileOnce || !isMobile && this._searchDesktopOnce) return;
|
||||
const classSuffix = isMobile ? 'mobile' : 'desktop';
|
||||
const $header = document.getElementById(`header-${classSuffix}`);
|
||||
const $searchInput = document.getElementById(`search-input-${classSuffix}`);
|
||||
const $searchToggle = document.getElementById(`search-toggle-${classSuffix}`);
|
||||
const $searchLoading = document.getElementById(`search-loading-${classSuffix}`);
|
||||
const $searchClear = document.getElementById(`search-clear-${classSuffix}`);
|
||||
if (isMobile) {
|
||||
this._searchMobileOnce = true;
|
||||
$searchInput.addEventListener('focus', () => {
|
||||
document.body.classList.add('blur');
|
||||
$header.classList.add('open');
|
||||
}, false);
|
||||
document.getElementById('search-cancel-mobile').addEventListener('click', () => {
|
||||
$header.classList.remove('open');
|
||||
document.body.classList.remove('blur');
|
||||
document.getElementById('menu-toggle-mobile').classList.remove('active');
|
||||
document.getElementById('menu-mobile').classList.remove('active');
|
||||
$searchLoading.style.display = 'none';
|
||||
$searchClear.style.display = 'none';
|
||||
this._searchMobile && this._searchMobile.autocomplete.setVal('');
|
||||
}, false);
|
||||
$searchClear.addEventListener('click', () => {
|
||||
$searchClear.style.display = 'none';
|
||||
this._searchMobile && this._searchMobile.autocomplete.setVal('');
|
||||
}, false);
|
||||
this._searchMobileOnClickMask = this._searchMobileOnClickMask || (() => {
|
||||
$header.classList.remove('open');
|
||||
$searchLoading.style.display = 'none';
|
||||
$searchClear.style.display = 'none';
|
||||
this._searchMobile && this._searchMobile.autocomplete.setVal('');
|
||||
});
|
||||
if (this.util.isMobile()) {
|
||||
menuToggleMobile.onclick = () => {
|
||||
menuToggleMobile.classList.toggle('active');
|
||||
menuMobile.classList.toggle('active');
|
||||
};
|
||||
this.scrollEventSet.add(this._menuMobileOnScroll);
|
||||
} else {
|
||||
this.scrollEventSet.delete(this._menuMobileOnScroll);
|
||||
}
|
||||
}
|
||||
|
||||
initSwitchTheme() {
|
||||
this.util.forEach(document.getElementsByClassName('theme-switch'), (button) => {
|
||||
button.onclick = () => {
|
||||
document.body.classList.toggle('dark-theme');
|
||||
window.isDark = !window.isDark;
|
||||
window.localStorage && window.localStorage.setItem('theme', window.isDark ? 'dark' : 'light');
|
||||
for (let event of this.switchThemeEventSet) event();
|
||||
};
|
||||
this.clickMaskEventSet.add(this._searchMobileOnClickMask);
|
||||
} else {
|
||||
this._searchDesktopOnce = true;
|
||||
$searchToggle.addEventListener('click', () => {
|
||||
document.body.classList.add('blur');
|
||||
$header.classList.add('open');
|
||||
$searchInput.focus();
|
||||
}, false);
|
||||
$searchClear.addEventListener('click', () => {
|
||||
$searchClear.style.display = 'none';
|
||||
this._searchDesktop && this._searchDesktop.autocomplete.setVal('');
|
||||
}, false);
|
||||
this._searchDesktopOnClickMask = this._searchDesktopOnClickMask || (() => {
|
||||
$header.classList.remove('open');
|
||||
$searchLoading.style.display = 'none';
|
||||
$searchClear.style.display = 'none';
|
||||
this._searchDesktop && this._searchDesktop.autocomplete.setVal('');
|
||||
});
|
||||
this.clickMaskEventSet.add(this._searchDesktopOnClickMask);
|
||||
}
|
||||
$searchInput.addEventListener('input', () => {
|
||||
if ($searchInput.value === '') $searchClear.style.display = 'none';
|
||||
else $searchClear.style.display = 'inline';
|
||||
}, false);
|
||||
|
||||
initHighlight() {
|
||||
this.util.forEach(document.querySelectorAll('.highlight > .chroma'), (block) => {
|
||||
const codes = block.querySelectorAll('pre.chroma > code');
|
||||
const code = codes[codes.length - 1];
|
||||
const lang = code ? code.className.toLowerCase() : '';
|
||||
block.className += ' ' + lang;
|
||||
});
|
||||
this.util.forEach(document.querySelectorAll('.highlight > pre.chroma'), (block) => {
|
||||
const chroma = document.createElement('div');
|
||||
chroma.className = block.className;
|
||||
const table = document.createElement('table');
|
||||
chroma.appendChild(table);
|
||||
const tbody = document.createElement('tbody');
|
||||
table.appendChild(tbody);
|
||||
const tr = document.createElement('tr');
|
||||
tbody.appendChild(tr);
|
||||
const td = document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
block.parentElement.replaceChild(chroma, block);
|
||||
td.appendChild(block);
|
||||
});
|
||||
}
|
||||
|
||||
initTable() {
|
||||
this.util.forEach(document.querySelectorAll('.content table'), (table) => {
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.className = 'table-wrapper';
|
||||
table.parentElement.replaceChild(wrapper, table);
|
||||
wrapper.appendChild(table);
|
||||
});
|
||||
}
|
||||
|
||||
initHeaderLink() {
|
||||
for (let num = 1; num <= 6; num++) {
|
||||
this.util.forEach(document.querySelectorAll('.page.single .content > h' + num), (header) => {
|
||||
header.classList.add('headerLink');
|
||||
header.innerHTML = `<a href="#${header.id}" class="header-mark"></a>${header.innerHTML}`;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initToc() {
|
||||
const tocCore = document.getElementById('TableOfContents');
|
||||
if (tocCore === null) return;
|
||||
if (this.util.isTocStatic()) {
|
||||
const tocContentStatic = document.getElementById('toc-content-static');
|
||||
if (tocCore.parentElement !== tocContentStatic) {
|
||||
tocCore.parentElement.removeChild(tocCore);
|
||||
tocContentStatic.appendChild(tocCore);
|
||||
}
|
||||
if (this._tocOnScroll) this.scrollEventSet.delete(this._tocOnScroll);
|
||||
} else {
|
||||
const tocContentAuto = document.getElementById('toc-content-auto');
|
||||
if (tocCore.parentElement !== tocContentAuto) {
|
||||
tocCore.parentElement.removeChild(tocCore);
|
||||
tocContentAuto.appendChild(tocCore);
|
||||
}
|
||||
const toc = document.getElementById('toc-auto');
|
||||
const page = document.getElementsByClassName('page')[0];
|
||||
toc.style.maxWidth = `${page.getBoundingClientRect().left - 20}px`;
|
||||
this._tocLinks = this._tocLinks || tocCore.getElementsByTagName('a');
|
||||
this._tocLis = this._tocLis || tocCore.getElementsByTagName('li');
|
||||
this._headerLinks = this._headerLinks || document.getElementsByClassName('headerLink');
|
||||
const headerIsFixed = window.desktopHeaderMode !== 'normal';
|
||||
const headerHeight = document.getElementById('header-desktop').offsetHeight;
|
||||
const TOP_SPACING = 20 + (headerIsFixed ? headerHeight : 0);
|
||||
const minTocTop = toc.offsetTop;
|
||||
const minScrollTop = minTocTop - TOP_SPACING + (headerIsFixed ? 0 : headerHeight);
|
||||
this._tocOnScroll = this._tocOnScroll || (() => {
|
||||
const footerTop = document.getElementById('post-footer').offsetTop;
|
||||
const maxTocTop = footerTop - toc.getBoundingClientRect().height;
|
||||
const maxScrollTop = maxTocTop - TOP_SPACING + (headerIsFixed ? 0 : headerHeight);
|
||||
const rect = page.getBoundingClientRect();
|
||||
if (this.newScrollTop < minScrollTop) {
|
||||
toc.style.position = 'absolute';
|
||||
toc.style.top = `${minTocTop}px`;
|
||||
toc.style.left = `${rect.width + 20}px`;
|
||||
} else if (this.newScrollTop > maxScrollTop) {
|
||||
toc.style.position = 'absolute';
|
||||
toc.style.top = `${maxTocTop}px`;
|
||||
toc.style.left = `${rect.width + 20}px`;
|
||||
} else {
|
||||
toc.style.position = 'fixed';
|
||||
toc.style.top = `${TOP_SPACING}px`;
|
||||
toc.style.left = `${rect.left + rect.width + 20}px`;
|
||||
}
|
||||
|
||||
this.util.forEach(this._tocLinks, (link) => { link.classList.remove('active'); });
|
||||
this.util.forEach(this._tocLis, (link) => { link.classList.remove('has-active'); });
|
||||
const INDEX_SPACING = 20 + (headerIsFixed ? headerHeight : 0);
|
||||
let activeTocIndex = this._headerLinks.length - 1;
|
||||
for (let i = 0; i < this._headerLinks.length - 1; i++) {
|
||||
const thisTop = this._headerLinks[i].getBoundingClientRect().top;
|
||||
const nextTop = this._headerLinks[i + 1].getBoundingClientRect().top;
|
||||
if ((i == 0 && thisTop > INDEX_SPACING)
|
||||
|| (thisTop <= INDEX_SPACING && nextTop > INDEX_SPACING)) {
|
||||
activeTocIndex = i;
|
||||
break;
|
||||
const CONTEXT_LENGTH = 200;
|
||||
const initAutosearch = () => {
|
||||
const autosearch = autocomplete(`#search-input-${classSuffix}`, {
|
||||
hint: false,
|
||||
autoselect: true,
|
||||
dropdownMenuContainer: `#search-dropdown-${classSuffix}`,
|
||||
clearOnSelected: true,
|
||||
cssClasses: { noPrefix: true },
|
||||
// debug: true,
|
||||
}, {
|
||||
name: 'search',
|
||||
source: (query, callback) => {
|
||||
$searchLoading.style.display = 'inline';
|
||||
$searchClear.style.display = 'none';
|
||||
const finish = (results) => {
|
||||
$searchLoading.style.display = 'none';
|
||||
$searchClear.style.display = 'inline';
|
||||
callback(results);
|
||||
};
|
||||
if (searchConfig.type === 'lunr') {
|
||||
const search = () => {
|
||||
if (lunr.queryHandler) query = lunr.queryHandler(query);
|
||||
return this._index.search(query).slice(0, 12).map(({ ref, matchData: { metadata } }) => {
|
||||
const matchData = this._indexData[ref];
|
||||
let { title, content: context } = matchData;
|
||||
let position = 0;
|
||||
Object.values(metadata).forEach(({ description, content }) => {
|
||||
if (description) {
|
||||
context = matchData.description;
|
||||
position = -1;
|
||||
} else if (content) {
|
||||
const matchPosition = content.position[0][0];
|
||||
if (matchPosition < position || position === 0) position = matchPosition;
|
||||
}
|
||||
});
|
||||
position -= CONTEXT_LENGTH / 5;
|
||||
if (position > 0) {
|
||||
position += context.substr(position, 25).lastIndexOf(' ') + 1;
|
||||
context = '...' + context.substr(position, CONTEXT_LENGTH);
|
||||
} else {
|
||||
context = context.substr(0, CONTEXT_LENGTH);
|
||||
}
|
||||
Object.keys(metadata).forEach(key => {
|
||||
title = title.replace(new RegExp(`(${key})`, 'gi'), '<em>$1</em>');
|
||||
context = context.replace(new RegExp(`(${key})`, 'gi'), '<em>$1</em>');
|
||||
});
|
||||
return {
|
||||
'uri': matchData.uri,
|
||||
'title' : title,
|
||||
'date' : matchData.date,
|
||||
'context' : context,
|
||||
};
|
||||
});
|
||||
}
|
||||
if (!this._index) {
|
||||
fetch(searchConfig.lunrIndexURL)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const indexData = {};
|
||||
this._index = lunr(function () {
|
||||
if (searchConfig.lunrLanguageCode) this.use(lunr[searchConfig.lunrLanguageCode]);
|
||||
this.ref('uri');
|
||||
this.field('title', { boost: 50 });
|
||||
this.field('tags', { boost: 20 });
|
||||
this.field('description', { boost: 10 });
|
||||
this.field('content', { boost: 5 });
|
||||
this.metadataWhitelist = ['position'];
|
||||
data.forEach((record) => {
|
||||
indexData[record.uri] = record;
|
||||
this.add(record);
|
||||
});
|
||||
});
|
||||
this._indexData = indexData;
|
||||
finish(search());
|
||||
}).catch(err => {
|
||||
console.error(err);
|
||||
finish([]);
|
||||
});
|
||||
} else finish(search());
|
||||
} else if (searchConfig.type === 'algolia') {
|
||||
$searchLoading.style.display = 'inline';
|
||||
$searchClear.style.display = 'none';
|
||||
this._algoliaIndex = this._algoliaIndex || algoliasearch(searchConfig.algoliaAppID, searchConfig.algoliaSearchKey).initIndex(searchConfig.algoliaIndex);
|
||||
this._algoliaIndex
|
||||
.search(query, { offset: 0, length: 12, attributesToHighlight: ['title', 'content'] })
|
||||
.then(({ hits }) => {
|
||||
finish(hits.map(({ uri, date, _highlightResult: { title, content } }) => ({
|
||||
uri: uri,
|
||||
title: title.value,
|
||||
date: date,
|
||||
context: content.value,
|
||||
})));
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
finish([]);
|
||||
});
|
||||
}
|
||||
if (activeTocIndex !== -1) {
|
||||
this._tocLinks[activeTocIndex].classList.add('active');
|
||||
let parent = this._tocLinks[activeTocIndex].parentElement;
|
||||
while (parent !== tocCore) {
|
||||
parent.classList.add('has-active');
|
||||
parent = parent.parentElement.parentElement;
|
||||
}
|
||||
}
|
||||
});
|
||||
this._tocOnScroll();
|
||||
this.scrollEventSet.add(this._tocOnScroll);
|
||||
}
|
||||
}
|
||||
|
||||
initMermaid() {
|
||||
const elements = document.getElementsByClassName('mermaid');
|
||||
if (elements.length) {
|
||||
mermaid.initialize({startOnLoad: false, theme: 'null'});
|
||||
this.util.forEach(elements, (element) => {
|
||||
mermaid.mermaidAPI.render('svg-' + element.id, window.contentMap[element.id], (svgCode) => {
|
||||
element.innerHTML = svgCode;
|
||||
}, element);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initEcharts() {
|
||||
this._echartsOnSwitchTheme = this._echartsOnSwitchTheme || (() => {
|
||||
this._echartsArr = this._echartsArr || [];
|
||||
for (let i = 0; i < this._echartsArr.length; i++) {
|
||||
this._echartsArr[i].dispose();
|
||||
}
|
||||
this._echartsArr = [];
|
||||
this.util.forEach(document.getElementsByClassName('echarts'), (element) => {
|
||||
const chart = echarts.init(element, window.isDark ? 'dark' : 'macarons', {renderer: 'svg'});
|
||||
chart.setOption(JSON.parse(window.contentMap[element.id]));
|
||||
this._echartsArr.push(chart);
|
||||
});
|
||||
},
|
||||
templates: {
|
||||
suggestion: ({ title, date, context }) => `<div><span class="suggestion-title">${title}</span><span class="suggestion-date">${date}</span></div><div class="suggestion-context">${context}</div>`,
|
||||
empty: ({ query }) => `<div class="search-empty">${searchConfig.noResultsFound}: <span class="search-query">"${query}"</span></div>`,
|
||||
footer: ({}) => {
|
||||
const { searchType, icon, href } = searchConfig.type === 'algolia' ? {
|
||||
searchType: 'algolia',
|
||||
icon: '<i class="fab fa-algolia fa-fw"></i>',
|
||||
href: 'https://www.algolia.com/',
|
||||
} : {
|
||||
searchType: 'Lunr.js',
|
||||
icon: '',
|
||||
href: 'https://lunrjs.com/',
|
||||
};
|
||||
return `<div class="search-footer">Search by <a href="${href}" rel="noopener noreffer" target="_blank">${icon} ${searchType}</a></div>`;},
|
||||
},
|
||||
});
|
||||
this.switchThemeEventSet.add(this._echartsOnSwitchTheme);
|
||||
this._echartsOnSwitchTheme();
|
||||
this._echartsOnResize = this._echartsOnResize || (() => {
|
||||
for (let i = 0; i < this._echartsArr.length; i++) {
|
||||
this._echartsArr[i].resize();
|
||||
autosearch.on('autocomplete:selected', (event, suggestion, dataset, context) => {
|
||||
window.location.assign(suggestion.uri);
|
||||
});
|
||||
if (isMobile) this._searchMobile = autosearch;
|
||||
else this._searchDesktop = autosearch;
|
||||
};
|
||||
if (searchConfig.lunrSegmentitURL && !document.getElementById('lunr-segmentit')) {
|
||||
const script = document.createElement('script');
|
||||
script.id = 'lunr-segmentit';
|
||||
script.type = 'text/javascript';
|
||||
script.src = searchConfig.lunrSegmentitURL;
|
||||
script.async = true;
|
||||
if (script.readyState) {
|
||||
script.onreadystatechange = () => {
|
||||
if (script.readyState == 'loaded' || script.readyState == 'complete'){
|
||||
script.onreadystatechange = null;
|
||||
initAutosearch();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
script.onload = () => {
|
||||
initAutosearch();
|
||||
};
|
||||
}
|
||||
document.body.appendChild(script);
|
||||
} else initAutosearch();
|
||||
}
|
||||
|
||||
initLightGallery() {
|
||||
if (this.config.lightGallery) lightGallery(document.getElementById('content'), this.config.lightGallery);
|
||||
}
|
||||
|
||||
initHighlight() {
|
||||
this.util.forEach(document.querySelectorAll('.highlight > .chroma'), $chroma => {
|
||||
const $codes = $chroma.querySelectorAll('pre.chroma > code');
|
||||
const $code = $codes[$codes.length - 1];
|
||||
const lang = $code ? $code.className.toLowerCase() : '';
|
||||
$chroma.className += ' ' + lang;
|
||||
});
|
||||
this.util.forEach(document.querySelectorAll('.highlight > pre.chroma'), $preChroma => {
|
||||
const $chroma = document.createElement('div');
|
||||
$chroma.className = $preChroma.className;
|
||||
const $table = document.createElement('table');
|
||||
$chroma.appendChild($table);
|
||||
const $tbody = document.createElement('tbody');
|
||||
$table.appendChild($tbody);
|
||||
const $tr = document.createElement('tr');
|
||||
$tbody.appendChild($tr);
|
||||
const $td = document.createElement('td');
|
||||
$tr.appendChild($td);
|
||||
$preChroma.parentElement.replaceChild($chroma, $preChroma);
|
||||
$td.appendChild($preChroma);
|
||||
});
|
||||
}
|
||||
|
||||
initTable() {
|
||||
this.util.forEach(document.querySelectorAll('.content table'), $table => {
|
||||
const $wrapper = document.createElement('div');
|
||||
$wrapper.className = 'table-wrapper';
|
||||
$table.parentElement.replaceChild($wrapper, $table);
|
||||
$wrapper.appendChild($table);
|
||||
});
|
||||
}
|
||||
|
||||
initHeaderLink() {
|
||||
for (let num = 1; num <= 6; num++) {
|
||||
this.util.forEach(document.querySelectorAll('.page.single .content > h' + num), $header => {
|
||||
$header.classList.add('headerLink');
|
||||
$header.innerHTML = `<a href="#${$header.id}" class="header-mark"></a>${$header.innerHTML}`;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initToc() {
|
||||
const $tocCore = document.getElementById('TableOfContents');
|
||||
if ($tocCore === null) return;
|
||||
if (this.util.isTocStatic()) {
|
||||
const $tocContentStatic = document.getElementById('toc-content-static');
|
||||
if ($tocCore.parentElement !== $tocContentStatic) {
|
||||
$tocCore.parentElement.removeChild($tocCore);
|
||||
$tocContentStatic.appendChild($tocCore);
|
||||
}
|
||||
if (this._tocOnScroll) this.scrollEventSet.delete(this._tocOnScroll);
|
||||
} else {
|
||||
const $tocContentAuto = document.getElementById('toc-content-auto');
|
||||
if ($tocCore.parentElement !== $tocContentAuto) {
|
||||
$tocCore.parentElement.removeChild($tocCore);
|
||||
$tocContentAuto.appendChild($tocCore);
|
||||
}
|
||||
const $toc = document.getElementById('toc-auto');
|
||||
const $page = document.getElementsByClassName('page')[0];
|
||||
const rect = $page.getBoundingClientRect();
|
||||
$toc.style.left = `${rect.left + rect.width + 20}px`;
|
||||
$toc.style.maxWidth = `${$page.getBoundingClientRect().left - 20}px`;
|
||||
const $tocLinkElements = $tocCore.getElementsByTagName('a');
|
||||
const $tocLiElements = $tocCore.getElementsByTagName('li');
|
||||
const $headerLinkElements = document.getElementsByClassName('headerLink');
|
||||
const headerIsFixed = this.config.desktopHeaderMode !== 'normal';
|
||||
const headerHeight = document.getElementById('header-desktop').offsetHeight;
|
||||
const TOP_SPACING = 20 + (headerIsFixed ? headerHeight : 0);
|
||||
const minTocTop = $toc.offsetTop;
|
||||
const minScrollTop = minTocTop - TOP_SPACING + (headerIsFixed ? 0 : headerHeight);
|
||||
this._tocOnScroll = this._tocOnScroll || (() => {
|
||||
const footerTop = document.getElementById('post-footer').offsetTop;
|
||||
const maxTocTop = footerTop - $toc.getBoundingClientRect().height;
|
||||
const maxScrollTop = maxTocTop - TOP_SPACING + (headerIsFixed ? 0 : headerHeight);
|
||||
if (this.newScrollTop < minScrollTop) {
|
||||
$toc.style.position = 'absolute';
|
||||
$toc.style.top = `${minTocTop}px`;
|
||||
} else if (this.newScrollTop > maxScrollTop) {
|
||||
$toc.style.position = 'absolute';
|
||||
$toc.style.top = `${maxTocTop}px`;
|
||||
} else {
|
||||
$toc.style.position = 'fixed';
|
||||
$toc.style.top = `${TOP_SPACING}px`;
|
||||
}
|
||||
|
||||
this.util.forEach($tocLinkElements, link => { link.classList.remove('active'); });
|
||||
this.util.forEach($tocLiElements, link => { link.classList.remove('has-active'); });
|
||||
const INDEX_SPACING = 20 + (headerIsFixed ? headerHeight : 0);
|
||||
let activeTocIndex = $headerLinkElements.length - 1;
|
||||
for (let i = 0; i < $headerLinkElements.length - 1; i++) {
|
||||
const thisTop = $headerLinkElements[i].getBoundingClientRect().top;
|
||||
const nextTop = $headerLinkElements[i + 1].getBoundingClientRect().top;
|
||||
if ((i == 0 && thisTop > INDEX_SPACING)
|
||||
|| (thisTop <= INDEX_SPACING && nextTop > INDEX_SPACING)) {
|
||||
activeTocIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (activeTocIndex !== -1) {
|
||||
$tocLinkElements[activeTocIndex].classList.add('active');
|
||||
let $parent = $tocLinkElements[activeTocIndex].parentElement;
|
||||
while ($parent !== $tocCore) {
|
||||
$parent.classList.add('has-active');
|
||||
$parent = $parent.parentElement.parentElement;
|
||||
}
|
||||
}
|
||||
});
|
||||
this.resizeEventSet.add(this._echartsOnResize);
|
||||
this._tocOnScroll();
|
||||
this.scrollEventSet.add(this._tocOnScroll);
|
||||
}
|
||||
}
|
||||
|
||||
initMapbox() {
|
||||
initMath() {
|
||||
if (this.config.math) renderMathInElement(document.body, this.config.math);
|
||||
}
|
||||
|
||||
initMermaid() {
|
||||
const $mermaidElements = document.getElementsByClassName('mermaid');
|
||||
if ($mermaidElements.length) {
|
||||
mermaid.initialize({startOnLoad: false, theme: 'null'});
|
||||
this.util.forEach($mermaidElements, element => {
|
||||
mermaid.mermaidAPI.render('svg-' + element.id, this.contentData[element.id], svgCode => {
|
||||
element.innerHTML = svgCode;
|
||||
}, element);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initEcharts() {
|
||||
this._echartsOnSwitchTheme = this._echartsOnSwitchTheme || (() => {
|
||||
this._echartsArr = this._echartsArr || [];
|
||||
for (let i = 0; i < this._echartsArr.length; i++) {
|
||||
this._echartsArr[i].dispose();
|
||||
}
|
||||
this._echartsArr = [];
|
||||
this.util.forEach(document.getElementsByClassName('echarts'), element => {
|
||||
const chart = echarts.init(element, this.isDark ? 'dark' : 'macarons', {renderer: 'svg'});
|
||||
chart.setOption(JSON.parse(this.contentData[element.id]));
|
||||
this._echartsArr.push(chart);
|
||||
});
|
||||
});
|
||||
this.switchThemeEventSet.add(this._echartsOnSwitchTheme);
|
||||
this._echartsOnSwitchTheme();
|
||||
this._echartsOnResize = this._echartsOnResize || (() => {
|
||||
for (let i = 0; i < this._echartsArr.length; i++) {
|
||||
this._echartsArr[i].resize();
|
||||
}
|
||||
});
|
||||
this.resizeEventSet.add(this._echartsOnResize);
|
||||
}
|
||||
|
||||
initMapbox() {
|
||||
if (this.config.mapbox) {
|
||||
mapboxgl.accessToken = this.config.mapbox.accessToken;
|
||||
mapboxgl.setRTLTextPlugin(this.config.mapbox.RTLTextPlugin);
|
||||
this._mapboxArr = this._mapboxArr || [];
|
||||
this.util.forEach(document.getElementsByClassName('mapbox'), (element) => {
|
||||
const options = window.contentMap[element.id];
|
||||
this.util.forEach(document.getElementsByClassName('mapbox'), element => {
|
||||
const { lng, lat, zoom, lightStyle, darkStyle, marked, navigation, geolocate, scale, fullscreen } = this.contentData[element.id];
|
||||
const options = this.contentData[element.id];
|
||||
const mapbox = new mapboxgl.Map({
|
||||
container: element,
|
||||
center: [options['lng'], options['lat']],
|
||||
zoom: options['zoom'],
|
||||
center: [lng, lat],
|
||||
zoom: zoom,
|
||||
minZoom: .2,
|
||||
style: window.isDark ? options['dark-style'] : options['light-style'],
|
||||
style: this.isDark ? darkStyle : lightStyle,
|
||||
attributionControl: false,
|
||||
});
|
||||
if (options['marked']) {
|
||||
new mapboxgl.Marker().setLngLat([options['lng'], options['lat']]).addTo(mapbox);
|
||||
if (marked) {
|
||||
new mapboxgl.Marker().setLngLat([lng, lat]).addTo(mapbox);
|
||||
}
|
||||
if (options['navigation']) {
|
||||
if (navigation) {
|
||||
mapbox.addControl(new mapboxgl.NavigationControl(), 'bottom-right');
|
||||
}
|
||||
if (options['geolocate']) {
|
||||
if (geolocate) {
|
||||
mapbox.addControl(new mapboxgl.GeolocateControl({
|
||||
positionOptions: {
|
||||
enableHighAccuracy: true,
|
||||
|
@ -237,150 +448,166 @@
|
|||
trackUserLocation: true,
|
||||
}), 'bottom-right');
|
||||
}
|
||||
if (options['scale']) {
|
||||
if (scale) {
|
||||
mapbox.addControl(new mapboxgl.ScaleControl());
|
||||
}
|
||||
if (options['fullscreen']) {
|
||||
if (fullscreen) {
|
||||
mapbox.addControl(new mapboxgl.FullscreenControl());
|
||||
}
|
||||
mapbox.addControl(new MapboxLanguage());
|
||||
this._mapboxArr.push(mapbox);
|
||||
});
|
||||
this._mapboxOnSwitchTheme = this._mapboxOnSwitchTheme || (() => {
|
||||
this.util.forEach(this._mapboxArr, (mapbox) => {
|
||||
this.util.forEach(this._mapboxArr, mapbox => {
|
||||
const element = mapbox.getContainer();
|
||||
const options = window.contentMap[element.id];
|
||||
mapbox.setStyle(window.isDark ? options['dark-style'] : options['light-style']);
|
||||
const { lightStyle, darkStyle } = this.contentData[element.id];
|
||||
mapbox.setStyle(this.isDark ? darkStyle : lightStyle);
|
||||
mapbox.addControl(new MapboxLanguage());
|
||||
});
|
||||
});
|
||||
this.switchThemeEventSet.add(this._mapboxOnSwitchTheme);
|
||||
}
|
||||
}
|
||||
|
||||
initTypeit() {
|
||||
if (window.typeitArr) {
|
||||
for (let i = 0; i < window.typeitArr.length; i++) {
|
||||
const group = window.typeitArr[i];
|
||||
(function typeone(i) {
|
||||
const id = group[i];
|
||||
if (i === group.length - 1) {
|
||||
new TypeIt(`#${id}`, {
|
||||
strings: window.contentMap[id],
|
||||
}).go();
|
||||
return;
|
||||
}
|
||||
let instance = new TypeIt(`#${id}`, {
|
||||
strings: window.contentMap[id],
|
||||
afterComplete: () => {
|
||||
instance.destroy();
|
||||
typeone(i + 1);
|
||||
},
|
||||
initTypeit() {
|
||||
if (this.config.typeit) {
|
||||
const typeitData = this.config.typeit;
|
||||
for (let i = 0; i < typeitData.length; i++) {
|
||||
const group = typeitData[i];
|
||||
((i) => {
|
||||
const id = group[i];
|
||||
if (i === group.length - 1) {
|
||||
new TypeIt(`#${id}`, {
|
||||
strings: this.contentData[id],
|
||||
}).go();
|
||||
})(0);
|
||||
return;
|
||||
}
|
||||
let instance = new TypeIt(`#${id}`, {
|
||||
strings: this.contentData[id],
|
||||
afterComplete: () => {
|
||||
instance.destroy();
|
||||
typeone(i + 1);
|
||||
},
|
||||
}).go();
|
||||
})(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initComment() {
|
||||
if (this.config.comment && this.config.comment.gitalk) {
|
||||
this.config.comment.gitalk.body = decodeURI(window.location.href);
|
||||
const gitalk = new Gitalk(this.config.comment.gitalk.body);
|
||||
gitalk.render('gitalk');
|
||||
}
|
||||
if (this.config.comment && this.config.comment.valine) new Valine(this.config.comment.valine);
|
||||
}
|
||||
|
||||
initSmoothScroll() {
|
||||
if ((!this.util.isMobile() && this.config.desktopHeaderMode === 'normal')
|
||||
|| (this.util.isMobile() && this.config.mobileHeaderMode === 'normal')) {
|
||||
new SmoothScroll('[href^="#"]', {speed: 300, speedAsDuration: true});
|
||||
} else {
|
||||
new SmoothScroll('[href^="#"]', {speed: 300, speedAsDuration: true, header: '#header-desktop'});
|
||||
}
|
||||
}
|
||||
|
||||
onScroll() {
|
||||
const $headers = [];
|
||||
if (this.config.desktopHeaderMode === 'auto') $headers.push(document.getElementById('header-desktop'));
|
||||
if (this.config.mobileHeaderMode === 'auto') $headers.push(document.getElementById('header-mobile'));
|
||||
this.util.forEach($headers, $header => {
|
||||
$header.classList.add('animated');
|
||||
$header.classList.add('faster');
|
||||
});
|
||||
if (document.getElementById('comments')) {
|
||||
const $viewComments = document.getElementById('view-comments');
|
||||
$viewComments.href = `#comments`;
|
||||
$viewComments.style.display = 'block';
|
||||
}
|
||||
const $fixedButtons = document.getElementById('fixed-buttons');
|
||||
const MIN_SCROLL = 20;
|
||||
window.addEventListener('scroll', () => {
|
||||
this.newScrollTop = this.util.getScrollTop();
|
||||
const scroll = this.newScrollTop - this.oldScrollTop;
|
||||
this.util.forEach($headers, header => {
|
||||
if (scroll > MIN_SCROLL) {
|
||||
header.classList.remove('fadeInDown');
|
||||
header.classList.add('fadeOutUp');
|
||||
} else if (scroll < - MIN_SCROLL) {
|
||||
header.classList.remove('fadeOutUp');
|
||||
header.classList.add('fadeInDown');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initSmoothScroll() {
|
||||
if ((!this.util.isMobile() && window.desktopHeaderMode === 'normal')
|
||||
|| (this.util.isMobile() && window.mobileHeaderMode === 'normal')) {
|
||||
new SmoothScroll('[href^="#"]', {speed: 300, speedAsDuration: true});
|
||||
} else {
|
||||
new SmoothScroll('[href^="#"]', {speed: 300, speedAsDuration: true, header: '#header-desktop'});
|
||||
}
|
||||
}
|
||||
|
||||
onScroll() {
|
||||
const headers = [];
|
||||
if (window.desktopHeaderMode === 'auto') headers.push(document.getElementById('header-desktop'));
|
||||
if (window.mobileHeaderMode === 'auto') headers.push(document.getElementById('header-mobile'));
|
||||
this.util.forEach(headers, (header) => {
|
||||
header.classList.add('animated');
|
||||
header.classList.add('faster');
|
||||
});
|
||||
const comments = document.getElementsByClassName('comment');
|
||||
if (comments.length) {
|
||||
const button = document.getElementById('comment-button');
|
||||
button.href = `#${comments[0].id}`;
|
||||
button.style.display = 'block';
|
||||
if (this.newScrollTop > MIN_SCROLL) {
|
||||
if (scroll > MIN_SCROLL) {
|
||||
$fixedButtons.classList.remove('fadeIn');
|
||||
$fixedButtons.classList.add('fadeOut');
|
||||
} else if (scroll < - MIN_SCROLL) {
|
||||
$fixedButtons.style.display = 'block';
|
||||
$fixedButtons.classList.remove('fadeOut');
|
||||
$fixedButtons.classList.add('fadeIn');
|
||||
}
|
||||
} else {
|
||||
$fixedButtons.style.display = 'none';
|
||||
}
|
||||
const fixedButtons = document.getElementById('fixed-buttons');
|
||||
const MIN_SCROLL = 10;
|
||||
window.addEventListener('scroll', () => {
|
||||
this.newScrollTop = this.util.getScrollTop();
|
||||
const scroll = this.newScrollTop - this.oldScrollTop;
|
||||
this.util.forEach(headers, (header) => {
|
||||
if (scroll > MIN_SCROLL) {
|
||||
header.classList.remove('fadeInDown');
|
||||
header.classList.add('fadeOutUp');
|
||||
} else if (scroll < - MIN_SCROLL) {
|
||||
header.classList.remove('fadeOutUp');
|
||||
header.classList.add('fadeInDown');
|
||||
}
|
||||
});
|
||||
if (this.newScrollTop > 20) {
|
||||
if (scroll > MIN_SCROLL) {
|
||||
fixedButtons.classList.remove('fadeIn');
|
||||
fixedButtons.classList.add('fadeOut');
|
||||
} else if (scroll < - MIN_SCROLL) {
|
||||
fixedButtons.style.display = 'block';
|
||||
fixedButtons.classList.remove('fadeOut');
|
||||
fixedButtons.classList.add('fadeIn');
|
||||
}
|
||||
} else {
|
||||
fixedButtons.style.display = 'none';
|
||||
}
|
||||
if (!this._scrollTimeout) {
|
||||
this._scrollTimeout = window.setTimeout(() => {
|
||||
this._scrollTimeout = null;
|
||||
for (let event of this.scrollEventSet) event();
|
||||
}, 10);
|
||||
}
|
||||
this.oldScrollTop = this.newScrollTop;
|
||||
}, false);
|
||||
}
|
||||
|
||||
onResize() {
|
||||
window.addEventListener('resize', () => {
|
||||
if (!this._resizeTimeout) {
|
||||
this._resizeTimeout = window.setTimeout(() => {
|
||||
this._resizeTimeout = null;
|
||||
for (let event of this.resizeEventSet) event();
|
||||
this.initMenuMobile();
|
||||
this.initToc();
|
||||
this.initSmoothScroll();
|
||||
this.initMermaid()
|
||||
}, 100);
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
init() {
|
||||
this.initMenuMobile();
|
||||
this.initSwitchTheme();
|
||||
this.initHighlight();
|
||||
this.initTable();
|
||||
this.initHeaderLink();
|
||||
this.initMermaid();
|
||||
this.initEcharts();
|
||||
this.initMapbox();
|
||||
this.initTypeit();
|
||||
this.initToc();
|
||||
this.initSmoothScroll();
|
||||
|
||||
this.onScroll();
|
||||
this.onResize();
|
||||
}
|
||||
for (let event of this.scrollEventSet) event();
|
||||
this.oldScrollTop = this.newScrollTop;
|
||||
}, false);
|
||||
}
|
||||
|
||||
const themeInit = () => {
|
||||
const theme = new Theme();
|
||||
theme.init();
|
||||
};
|
||||
|
||||
if (document.readyState !== 'loading') {
|
||||
themeInit();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', themeInit, false);
|
||||
onResize() {
|
||||
window.addEventListener('resize', () => {
|
||||
if (!this._resizeTimeout) {
|
||||
this._resizeTimeout = window.setTimeout(() => {
|
||||
this._resizeTimeout = null;
|
||||
for (let event of this.resizeEventSet) event();
|
||||
this.initToc();
|
||||
this.initSmoothScroll();
|
||||
this.initMermaid();
|
||||
this.initSearch();
|
||||
}, 100);
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
})();
|
||||
|
||||
onClickMask() {
|
||||
document.getElementById('mask').addEventListener('click', () => {
|
||||
for (let event of this.clickMaskEventSet) event();
|
||||
document.body.classList.remove('blur');
|
||||
}, false);
|
||||
}
|
||||
|
||||
init() {
|
||||
this.initMenuMobile();
|
||||
this.initSwitchTheme();
|
||||
this.initSearch();
|
||||
this.initLightGallery();
|
||||
this.initHighlight();
|
||||
this.initTable();
|
||||
this.initHeaderLink();
|
||||
this.initMath();
|
||||
this.initMermaid();
|
||||
this.initEcharts();
|
||||
this.initMapbox();
|
||||
this.initTypeit();
|
||||
this.initToc();
|
||||
this.initComment();
|
||||
this.initSmoothScroll();
|
||||
|
||||
this.onScroll();
|
||||
this.onResize();
|
||||
this.onClickMask();
|
||||
}
|
||||
}
|
||||
|
||||
const themeInit = () => {
|
||||
const theme = new Theme();
|
||||
theme.init();
|
||||
};
|
||||
|
||||
if (document.readyState !== 'loading') {
|
||||
themeInit();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', themeInit, false);
|
||||
}
|
||||
|
|
8
src/lib/lunr.segmentit.js
Normal file
8
src/lib/lunr.segmentit.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { Segment, useDefault } from 'segmentit';
|
||||
|
||||
const segmentit = useDefault(new Segment());
|
||||
lunr.segmentit = segmentit;
|
||||
lunr.queryHandler = query => {
|
||||
if (/^[\u4e00-\u9fa5]+$/.test(query)) query = lunr.segmentit.doSegment(query).map(seg => '+' + seg.w).join(' ');
|
||||
return query;
|
||||
};
|
Loading…
Add table
Reference in a new issue