Skip to content

Commit

Permalink
✨ support waline & add hover shadow for card
Browse files Browse the repository at this point in the history
  • Loading branch information
YunYouJun committed Jan 30, 2021
1 parent 27efbaa commit db4370e
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 29 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,8 @@
module.exports = {
globals: {
hexo: "off",
CONFIG: "off",
Yun: "off",
anime: "off",
},
};
1 change: 1 addition & 0 deletions _vendors.yml
Expand Up @@ -45,6 +45,7 @@ vue: https://cdn.jsdelivr.net/npm/vue@2.6.11

# comment
valine_js: https://cdn.jsdelivr.net/npm/valine@latest/dist/Valine.min.js
waline_js: https://cdn.jsdelivr.net/npm/@waline/client/dist/Waline.min.js
minivaline_js: https://cdn.jsdelivr.net/npm/minivaline@latest
# https://github.com/SukkaW/DisqusJS
disqusjs:
Expand Down
5 changes: 5 additions & 0 deletions data/_comments.yml
Expand Up @@ -53,6 +53,11 @@ valine:
# - nick
# - mail

# https://waline.js.org/
waline:
enable: false
serverURL: # https://your-domain.vercel.app

# MiniValine
# More info available at https://github.com/MiniValine/MiniValine
minivaline:
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/post/post-meta.pug
Expand Up @@ -53,7 +53,7 @@
|
span#busuanzi_value_page_pv

if theme.leancloud_visitors && theme.leancloud_visitors.enable || (is_post() && theme.valine.enable && theme.valine.visitor)
if theme.leancloud_visitors && theme.leancloud_visitors.enable || (is_post() && theme.valine.enable && theme.valine.visitor) || (is_post() && theme.waline.enable && theme.waline.visitor)
span.leancloud_visitors(id=url_for(post.path), data-flag-title=post.title)
span.post-meta-divider='-'
span.post-meta-item-icon(title=__('post.views'))
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/recent-posts.pug
Expand Up @@ -2,7 +2,7 @@ section#recent-posts.hty-layout-grid
each post in page.posts.data
if !post.hide
.hty-layout-grid__cell.hty-layout-grid__cell--span-12
article.hty-card.post-card(itemscope, itemtype='https://schema.org/Article')
article.post-card(itemscope, itemtype='https://schema.org/Article')
include ../_partial/post/post-schema.pug
if post.top || post.sticky
.post-top-icon
Expand Down
4 changes: 3 additions & 1 deletion layout/_third-party/comments/index.pug
@@ -1,4 +1,4 @@
#comment
#comment.hty-card
.comment-tooltip.text-center
if theme.comment.tips
each tip in theme.comment.tips
Expand Down Expand Up @@ -49,6 +49,8 @@
include minivaline.pug
if theme.valine && theme.valine.enable
include valine.pug
if theme.waline && theme.waline.enable
include waline.pug
if theme.utterances && theme.utterances.enable
include utterances.pug
if theme.twikoo && theme.twikoo.enable
Expand Down
1 change: 0 additions & 1 deletion layout/_third-party/comments/valine.pug
@@ -1,7 +1,6 @@
//- not need js-Pjax
#valine-container
//- not use valine_config() for window.location.pathname
- var valine_meta = Array.isArray(theme.valine.meta) ? theme.valine.meta : ["nick", "mail", "link"]
- theme.valine.el = "#valine-container"
- theme.valine.lang = (theme.valine.lang || config.language || "zh-cn").toLowerCase()
script.
Expand Down
9 changes: 9 additions & 0 deletions layout/_third-party/comments/waline.pug
@@ -0,0 +1,9 @@
#waline
- theme.waline.el = "#waline"
- theme.waline.lang = (theme.waline.lang || config.language || "zh-CN")
script.
Yun.utils.getScript("#{theme.vendors.waline_js}", () => {
const walineConfig = !{JSON.stringify(theme.waline)}
walineConfig.path = window.location.pathname
new Waline(walineConfig)
}, window.Waline);
2 changes: 1 addition & 1 deletion layout/page.pug
@@ -1,7 +1,7 @@
extends _partial/layout.pug

block content
#page
#page.hty-card
if page.type === 'tags'
+page_header(page.title, 'icon-price-tag-3-line')
.page-subtitle=_p('counter.tag_cloud', site.tags.length)
Expand Down
2 changes: 1 addition & 1 deletion layout/post.pug
Expand Up @@ -5,7 +5,7 @@ block content
- var post_type = getPropertyByType(post.type)

#post
article.post-block(itemscope, itemtype='https://schema.org/Article')
article.hty-card.post-block(itemscope, itemtype='https://schema.org/Article')
include _partial/post/post-schema.pug
header.post-header
h1.post-title(itemprop='name headline', style=post.type ? `color: ${post_type.color}` : '')
Expand Down
2 changes: 1 addition & 1 deletion layout/tag.pug
Expand Up @@ -2,7 +2,7 @@ extends _partial/layout.pug

block content
include _mixin/post-collapse.pug
#tag
#tag.hty-card
+page_header(page.tag, 'icon-price-tag-3-line')
+post_collapse(page.posts)
include _partial/pagination.pug
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-yun",
"version": "1.4.0",
"version": "1.4.1",
"description": "☁️ A fast & light & lovely theme for Hexo.",
"repository": {
"type": "git",
Expand Down
37 changes: 23 additions & 14 deletions scripts/events/config.js
@@ -1,5 +1,27 @@
const { merge } = require("./utils");

/**
* 合并语言
* @param {*} hexo
* @param {*} languages
*/
function mergeLanguages(hexo, languages) {
const { language } = hexo.config;
const { i18n } = hexo.theme;

const mergeLang = (lang) => {
i18n.set(lang, merge(i18n.get([lang]), languages[lang]));
};

if (Array.isArray(language)) {
for (let lang of language) {
mergeLang(lang);
}
} else {
mergeLang(language);
}
}

module.exports = (hexo) => {
const data = hexo.locals.get("data");

Expand All @@ -19,19 +41,6 @@ module.exports = (hexo) => {

// merge languages
if (data.languages) {
let { language } = hexo.config;
let { i18n } = hexo.theme;

const mergeLang = (lang) => {
i18n.set(lang, merge(i18n.get([lang]), data.languages[lang]));
};

if (Array.isArray(language)) {
for (let lang of language) {
mergeLang(lang);
}
} else {
mergeLang(language);
}
mergeLanguages(hexo, data.languages);
}
};
1 change: 1 addition & 0 deletions scripts/helpers/encrypt.js
@@ -1,3 +1,4 @@
/*global hexo*/
hexo.extend.helper.register("aes", function(content, password) {
const CryptoJS = require("crypto-js");
return CryptoJS.AES.encrypt(content, password).toString();
Expand Down
13 changes: 8 additions & 5 deletions source/css/_components/card.styl
@@ -1,10 +1,13 @@
.hty- {
&card {
.hty {
&-card {
position: relative;
display: flex;
margin: 1rem;
the-transition();
flex-direction: column;
box-sizing: border-box;
the-transition();

&:hover {
box-shadow: 0 0 1rem rgba(0, 0, 0, 0.1);
}
}
}
}
4 changes: 2 additions & 2 deletions source/css/_layout/main.styl
@@ -1,3 +1,3 @@
#content {
overflow: hidden;
}
overflow: visible;
}
3 changes: 3 additions & 0 deletions source/css/_widget/comment.styl
Expand Up @@ -11,6 +11,9 @@
.comment-tooltip {
font-size: 0.8rem;
color: var(--hty-text-color);
padding: 0.5rem;
border: 1px solid #f0f0f0;
margin-bottom: 1rem;
}

#github-issues {
Expand Down

0 comments on commit db4370e

Please sign in to comment.