diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..6a9c3a673 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,8 @@ +module.exports = { + globals: { + hexo: "off", + CONFIG: "off", + Yun: "off", + anime: "off", + }, +}; diff --git a/_vendors.yml b/_vendors.yml index e0f9ba6b1..bc2c337e5 100644 --- a/_vendors.yml +++ b/_vendors.yml @@ -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: diff --git a/data/_comments.yml b/data/_comments.yml index 3b66250b7..9de76fd81 100644 --- a/data/_comments.yml +++ b/data/_comments.yml @@ -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: diff --git a/layout/_partial/post/post-meta.pug b/layout/_partial/post/post-meta.pug index 31934b3e0..d8d0e86bd 100644 --- a/layout/_partial/post/post-meta.pug +++ b/layout/_partial/post/post-meta.pug @@ -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')) diff --git a/layout/_partial/recent-posts.pug b/layout/_partial/recent-posts.pug index 86534bdcc..57dc13368 100644 --- a/layout/_partial/recent-posts.pug +++ b/layout/_partial/recent-posts.pug @@ -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 diff --git a/layout/_third-party/comments/index.pug b/layout/_third-party/comments/index.pug index c64c12638..682461010 100644 --- a/layout/_third-party/comments/index.pug +++ b/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 @@ -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 diff --git a/layout/_third-party/comments/valine.pug b/layout/_third-party/comments/valine.pug index 9ff452ec6..d3955eb6d 100644 --- a/layout/_third-party/comments/valine.pug +++ b/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. diff --git a/layout/_third-party/comments/waline.pug b/layout/_third-party/comments/waline.pug new file mode 100644 index 000000000..690907859 --- /dev/null +++ b/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); diff --git a/layout/page.pug b/layout/page.pug index 9e350358e..36f0bdf18 100644 --- a/layout/page.pug +++ b/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) diff --git a/layout/post.pug b/layout/post.pug index 63b27966b..e8d529721 100644 --- a/layout/post.pug +++ b/layout/post.pug @@ -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}` : '') diff --git a/layout/tag.pug b/layout/tag.pug index 84454a6da..7e13e44ca 100644 --- a/layout/tag.pug +++ b/layout/tag.pug @@ -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 diff --git a/package.json b/package.json index 2f1cc9ed3..89628000c 100644 --- a/package.json +++ b/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", diff --git a/scripts/events/config.js b/scripts/events/config.js index 2446a6b05..5f4e1f8b6 100644 --- a/scripts/events/config.js +++ b/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"); @@ -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); } }; diff --git a/scripts/helpers/encrypt.js b/scripts/helpers/encrypt.js index 7e17d97c8..b647a1de9 100644 --- a/scripts/helpers/encrypt.js +++ b/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(); diff --git a/source/css/_components/card.styl b/source/css/_components/card.styl index 085e671ca..2f2cdf9b0 100644 --- a/source/css/_components/card.styl +++ b/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); + } } -} \ No newline at end of file +} diff --git a/source/css/_layout/main.styl b/source/css/_layout/main.styl index 4922ca2fa..abd02ad12 100644 --- a/source/css/_layout/main.styl +++ b/source/css/_layout/main.styl @@ -1,3 +1,3 @@ #content { - overflow: hidden; -} \ No newline at end of file + overflow: visible; +} diff --git a/source/css/_widget/comment.styl b/source/css/_widget/comment.styl index 29454fd67..45ba822c5 100644 --- a/source/css/_widget/comment.styl +++ b/source/css/_widget/comment.styl @@ -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 {