Skip to content

Commit

Permalink
feat(meng): add meng title and meng cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
KeJunMao committed Jun 13, 2017
1 parent c6012c5 commit 2631e0a
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 8 deletions.
4 changes: 4 additions & 0 deletions _data/lang.yml
@@ -1,4 +1,6 @@
zh-CN:
page:
search: "搜索"
post:
continue: "阅读全文"
qrcode: "二维码"
Expand All @@ -16,6 +18,8 @@ zh-CN:
toTelegram: "分享到 Telegram"

en-US:
page:
search: "Search"
post:
continue: "Read more"
qrcode: "QR Code"
Expand Down
11 changes: 11 additions & 0 deletions _data/meng.yml
@@ -0,0 +1,11 @@
title: # Meng title
switch: true # Meng title switch
visible: "(*´∇`*) 被发现啦~" # State is visible text
hidden: "(つェ⊂)看不到我~" # State is hidden text
with_default_title: true # with default title
reset_time: 1000 # If state is visible , reset default title times(ms)

cursor: # cursor
switch: true # cursor switch
auto_url: "https://ooo.0o0.ooo/2017/06/12/593ea1901c930.png" # State is auto style
pointer_url: "https://ooo.0o0.ooo/2017/06/12/593ea3612fd77.png" # State is pointer style
1 change: 1 addition & 0 deletions _data/site.yml
Expand Up @@ -8,6 +8,7 @@ uiux:
android_chrome_color: "#eeeeee" # the color of the Chrome address bar
nprogress_color: "#29d" # the color of the top loading progress bar
nprogress_buffer: 200 # the top loading progress bar buffers
meng: false

background:
purecolor: "#eeeeee" # the background color
Expand Down
10 changes: 8 additions & 2 deletions _includes/header.html
@@ -1,3 +1,9 @@
{% if site.data.site.lang == 'zh-CN' %}
{% assign lang = site.data.lang[site.data.site.lang] %}
{% else %}
{% assign lang = site.data.lang.en-US %}
{% endif %}

{% for menu in site.data.menus %}
{% if menu.name == "navSearch" %}
{% if menu.switch == true %}
Expand All @@ -24,7 +30,7 @@
<div class="typeahead__container">
<div class="typeahead__field">
<span class="typeahead__query">
<input class="mdui-textfield-input k-nav-search" type="text" placeholder="Search"/>
<input class="mdui-textfield-input k-nav-search" type="text" placeholder="{{lang.page.search}}"/>
</span>
</div>
</div>
Expand All @@ -41,7 +47,7 @@
<div class="typeahead__field">
<span class="typeahead__query">
<i class="mdui-icon material-icons">&#xe8b6;</i>
<input class="mdui-textfield-input k-nav-search" type="text" placeholder="Search"/>
<input class="mdui-textfield-input k-nav-search" type="text" placeholder="{{lang.page.search}}"/>
</span>
</div>
</div>
Expand Down
30 changes: 30 additions & 0 deletions _includes/script.html
Expand Up @@ -5,6 +5,36 @@
<script>
(function($){$.fn.scrollToTop=function(options){var config={"speed":800};if(options){$.extend(config,{"speed":options})}return this.each(function(){var $this=$(this);$(window).scroll(function(){if($(this).scrollTop()>100){$this.fadeIn()}else{$this.fadeOut()}});$this.click(function(e){e.preventDefault();$("body, html").animate({scrollTop:0},config.speed)})})};$.fn.scrollBodyToTop=function(options){var config={"speed":800};if(options){$.extend(config,{"speed":options})}return this.each(function(){var $this=$(this);$(".placeholder").scroll(function(){if($(this).scrollTop()>100){$this.fadeIn()}else{$this.fadeOut()}});$this.click(function(e){e.preventDefault();$(".placeholder").animate({scrollTop:0},config.speed)})})}})(jQuery);
</script>
<!--/* global-meng-script-start */-->
{% if site.data.site.uiux.meng == true %}
{% if site.data.meng.title.switch == true %}
<script>
var defaultTitle = document.title;
{% if site.data.meng.title.with_default_title == true %}
var hiddenText = '{{site.data.meng.title.hidden}}' +' - '+ defaultTitle;
var visibleText = '{{site.data.meng.title.visible}}' +' - '+ defaultTitle;
{% else %}
var hiddenText = '{{site.data.meng.title.hidden}}';
var visibleText = '{{site.data.meng.title.visible}}';
{% endif %}
var resetTime = {{site.data.meng.title.reset_time}};
document.addEventListener("visibilitychange", function() {
if(document.visibilityState == "hidden" ){
document.title = hiddenText;
}
if(document.visibilityState == "visible"){
document.title = visibleText;
setTimeout(function(){
if(document.visibilityState == "visible"){
document.title = defaultTitle;
}
},resetTime);
}
}, false);
</script>
{% endif %}
{% endif %}
<!--/* global-meng-script-end */-->
<script type="text/javascript">
/* NProgress */
NProgress.configure({
Expand Down
14 changes: 14 additions & 0 deletions assets/css/main.css
Expand Up @@ -196,6 +196,20 @@ body,header,#toc-card{
opacity: .7;
}

{% if site.data.site.uiux.meng == true %}
{% if site.data.meng.cursor.switch == true %}
body{
cursor:url({{site.data.meng.cursor.auto_url}}), auto;
}
a{
cursor:url({{site.data.meng.cursor.pointer_url}}), pointer;
}
.k-post-media{
cursor:url({{site.data.meng.cursor.pointer_url}}), pointer;
}
{% endif %}
{% endif %}

{% for sns in site.data.sns %}
{% if sns.name =='bilibili' and sns.url != null %}
.k-bilibili{
Expand Down
5 changes: 4 additions & 1 deletion docs/zh-cn/_sidebar.md
Expand Up @@ -3,7 +3,7 @@
- [定制导航栏](zh-cn/custom-navbar.md)
- [创建页面](zh-cn/creating-pages.md)
- [定制 SNS](zh-cn/custom-sns.md)
- [](zh-cn/custom-sns.md)
- [更新主题](zh-cn/update-theme.md)

- 配置介绍
- [站点配置](zh-cn/site-configuration.md)
Expand All @@ -20,6 +20,9 @@

- 其他工具
- [fastjekyll](zh-cn/fastjekyll.md)
- [color tool](https://material.io/color/#!/?view.left=0&view.right=0)
- [Material icons](https://material.io/icons/)
- [MDUI 文档](https://www.mdui.org/docs/)

- 开发
- [如何贡献](zh-cn/how-contribution.md)
Expand Down
22 changes: 17 additions & 5 deletions docs/zh-cn/custom-navbar.md
Expand Up @@ -17,7 +17,7 @@
### 启用导航栏搜索

要启用导航栏搜索,只需将`name`字段为`navSearch``switch`设置为`true`即可:
要启用导航栏搜索,只需将`_data/menus.yml`文件的`name`字段为`navSearch``switch`设置为`true`即可:

```yaml
- name: navSearch
Expand All @@ -26,11 +26,13 @@

## 参数详解

### name
### 菜单

#### name

定义名称,名称会显示在导航栏中。

### url
#### url

定义文件路径。

Expand All @@ -42,6 +44,16 @@ url: /pages/test.html

则需在jekyll网站根目录新建一个pages文件夹,并创建一个test.html。

### icon
#### icon

定义图标,图标会在移动端的侧边栏显示。

### 导航栏搜索

#### name

必需,请勿更改

#### switch

定义图标,图标会在移动端的侧边栏显示
开关,`true`为启用
19 changes: 19 additions & 0 deletions docs/zh-cn/update-theme.md
@@ -0,0 +1,19 @@
# 更新主题

我们仅提供使用gem安装的更新方式。

## 如何使用

要更新主题,只要在终端使用`bundle`即可:

```bash
bundle update
```

## 注意事项

由于jekyll主题的特殊性,无法包括`_data`文件夹的内容,您需要手动更新这些文件。

访问 [Commits · KeJunMao/jekyll-theme-mdui](https://github.com/KeJunMao/jekyll-theme-mdui/commits/build) ,寻找`commits``feat(version)`开头的提交,然后查看改动,并按照改动修正已有的`_data`文件夹下的`.yml`文件即可。

当然,主题开发前期和大版本更新可能会有这个问题,一般不会影响正常使用,你大可不必理会。

0 comments on commit 2631e0a

Please sign in to comment.