Skip to content

Commit

Permalink
Merge pull request #46 from DuoSco/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
王卓Sco authored Dec 1, 2023
2 parents b7337e1 + f8e346b commit 9cb94b6
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 39 deletions.
13 changes: 13 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,22 @@ thirdparty:
comment:
enable: false # 是否开启评论
type: 'twikoo' # valine, twikoo
lazyload: true # 是否开启懒加载
count: true # 是否显示评论数
# 评论系统
twikoo:
envId: # url: https://twikoo.sondy.top/
lang: 'zh-CN' # 语言
accessToken: # accessToken
waline:
envId: https://waline.wzsco.top # url: https://waline.js.org/
pageview: true # 是否开启页面访问量统计
option: # waline配置项
visitor: true # 是否开启访客统计
highlight: true # 是否开启代码高亮
emojiCDN: 'https://cdn.jsdelivr.net/npm/emoji-datasource-apple@latest/img/apple/64/' # emoji CDN
admin: # 管理员邮箱
-

# 插入代码到头部 </head> 之前 和 底部 </body> 之前
# 插入额外代码 如:统计,广告等
Expand Down Expand Up @@ -502,6 +513,8 @@ cdn:
pacejs: https://cdn.bootcdn.net/ajax/libs/pace/1.2.4/pace.min.js
echartsjs: https://cdn.bootcdn.net/ajax/libs/echarts/5.4.2/echarts.min.js
lunrjs: https://cdn.bootcdn.net/ajax/libs/lunr.js/2.3.9/lunr.min.js
walinecss: https://cdn.bootcdn.net/ajax/libs/waline/2.15.7/waline.min.css
walinejs: https://cdn.bootcdn.net/ajax/libs/waline/2.15.7/waline.min.js
body:
viewimagejs: /lib/view-image.min.js
waterfalljs: /lib/waterfall.min.js
Expand Down
23 changes: 10 additions & 13 deletions layout/category.pug
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
extends includes/layout.pug

block content
main.layout#content-inner
div#category
div#category-bar
div.category-bar-items#category-bar-items
include includes/widgets/home/categoryBar
div.recent-posts#recent-posts
- const currentCategory = page.category
each post in site.posts.data
each category in post.categories.data
if category.name === currentCategory
include includes/widgets/home/postList
include includes/mixins/pagination
include includes/widgets/aside/aside
main.layout#content-inner
div#category
div#category-bar
div.category-bar-items#category-bar-items
include includes/widgets/home/categoryBar
div.recent-posts#recent-posts
each post in site.posts.find({ parent: { $exists: false } }).data
include includes/widgets/home/postList
include includes/mixins/pagination
include includes/widgets/aside/aside
8 changes: 6 additions & 2 deletions layout/includes/inject/head.pug
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ link(rel="stylesheet", href=cdn.snackbarcss)

// comment
if theme.comment.enable
if theme.comment.type === 'twikoo'
script(src=cdn.twikoojs)
case theme.comment.type
when 'twikoo'
script(src=cdn.twikoojs)
when 'waline'
script(src=cdn.walinejs)
link(rel="stylesheet", href=cdn.walinecss)

// search
if theme.thirdparty.search.enable
Expand Down
4 changes: 3 additions & 1 deletion layout/includes/widgets/third-party/comments/comment.pug
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ div#post-comment(view-image)
when 'gitalk'
include ./gitalk.pug
when 'valine'
include ./valine.pug
include ./valine.pug
when 'waline'
include ./waline.pug
17 changes: 17 additions & 0 deletions layout/includes/widgets/third-party/comments/waline.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- const { envId, option, pageview } = theme.comment.waline
- const { lazyload, count, type } = theme.comment

script.
async function initComment() {
(() => {
const waline = Waline.init(Object.assign({
el: '#comment',
serverURL: '!{envId}',
pageview: !{lazyload ? false : pageview},
dark: 'html[data-theme="dark"]',
path: window.location.pathname,
search: false,
comment: !{lazyload ? false : count},
}, !{JSON.stringify(option)}))
})()
}
29 changes: 13 additions & 16 deletions layout/tag.pug
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
extends includes/layout.pug

block content
main.layout#content-inner
div#tag
div#tag-page-tags
each tag in site.tags.find({ parent: { $exists: false } }).data
a(id=tag.name class=(tag.name === page.tag ? 'select' : '') href=url_for(tag.path))
span.tags-punctuation
| #{tag.name}
span.tagsPageCount #{tag.length}
div.recent-posts#recent-posts
- const currentTag = page.tag
each post in site.posts.data
each tag in post.tags.data
if tag.name === currentTag
include includes/widgets/home/postList
include includes/mixins/pagination
include includes/widgets/aside/aside
main.layout#content-inner
div#tag
div#tag-page-tags
each tag in site.tags.find({ parent: { $exists: false } }).data
a(id=tag.name class=(tag.name === page.tag ? 'select' : '') href=url_for(tag.path))
span.tags-punctuation
| #{tag.name}
span.tagsPageCount #{tag.length}
div.recent-posts#recent-posts
each post in site.posts.find({ parent: { $exists: false } }).data
include includes/widgets/home/postList
include includes/mixins/pagination
include includes/widgets/aside/aside
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-solitude",
"version": "1.2.3",
"version": "1.2.4",
"description": "A beautiful, powerful, and efficient Hexo theme developed by the DuoSco team",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
1 change: 1 addition & 0 deletions source/css/_layout/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
border-radius 12px
cursor pointer
border var(--style-border)
margin 1rem 0 1rem

&:hover
box-shadow var(--card-hover-box-shadow)
Expand Down
File renamed without changes.
File renamed without changes.
75 changes: 75 additions & 0 deletions source/css/_widgets/comment/waline.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#comment
.wl-sort li
color var(--sco-gray)

&.active
color var(--sco-main) !important

.wl-comment
.wl-panel
margin 0 !important

.wl-footer
.wl-info
button
background-color var(--sco-card-bg)
border var(--style-border-always)
color var(--sco-fontcolor)

button:hover
background-color var(--sco-main)
border-color var(--sco-main)
color var(--sco-card-bg)

#wl-edit
font-size 13px
line-height 1.5
margin .75rem .25rem

.wl-action
transition .3s

&:hover
color var(--sco-main)

.wl-meta-head
.wl-count
color var(--sco-gray)
font-size 14px
font-weight normal

.wl-cards
font-size 16px!important
.wl-comment-actions
button
margin-right 15px
font-size 18px

&:hover
color var(--sco-main)
.wl-head .wl-nick
font-size 20px !important
color var(--sco-lighttext)
font-weight bolder

.wl-meta>span
background var(--sco-gray)
border-radius 5px
color var(--sco-card-bg)
margin-right 5px

.wl-user
img
flex-shrink 0
height 2.5rem
width 2.5rem
overflow hidden
text-align center
border-radius 2.5rem
border 2px solid var(--sco-white)

[data-waline] a
color var(--sco-main) !important

.wl-content pre, .wl-content pre[class*=language-]
padding .5rem!important
5 changes: 3 additions & 2 deletions source/css/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ if hexo-config('css_prefix')

// comment
if hexo-config('comment.enable')
@import '_comment/index.styl'
@import '_comment/twikoo.styl' when hexo-config('comment.type') == 'twikoo'
@import '_widgets/comment/index.styl'
@import '_widgets/comment/twikoo.styl' when hexo-config('comment.type') == 'twikoo'
@import '_widgets/comment/waline.styl' when hexo-config('comment.type') == 'waline'

// commentBarrage
if hexo-config('thirdparty.comment.enable')
Expand Down
32 changes: 28 additions & 4 deletions source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ let sco = {

pageText.addEventListener("keydown", (event) => {
if (event.keyCode === 13) {
heo.toPage();
sco.toPage();
pjax.loadUrl(pageButton.href);
}
});
Expand Down Expand Up @@ -881,7 +881,29 @@ let sco = {
cookiesWindow.style.display = 'none';
}
}
}
},
/**
* 首页分页跳转
*/
toPage: function () {
const pageNumbers = document.querySelectorAll(".page-number");
const maxPageNumber = parseInt(pageNumbers[pageNumbers.length - 1].innerHTML);
const inputElement = document.getElementById("toPageText");
const inputPageNumber = parseInt(inputElement.value);

if (!isNaN(inputPageNumber) && inputPageNumber > 0 && inputPageNumber <= maxPageNumber) {
const currentPageUrl = window.location.href.replace(/\/page\/\d+\/$/, "/");
let targetPageUrl;

if (inputPageNumber === 1) {
targetPageUrl = currentPageUrl;
} else {
targetPageUrl = currentPageUrl + (currentPageUrl.endsWith("/") ? "" : "/") + "page/" + inputPageNumber + "/";
}

document.getElementById("toPageButton").href = targetPageUrl;
}
},
}

/*
Expand Down Expand Up @@ -1005,7 +1027,6 @@ window.refreshFn = () => {
GLOBAL_CONFIG.lazyload.enable && sco.lazyloadImg()
GLOBAL_CONFIG.lightbox && sco.lightbox('')
GLOBAL_CONFIG.randomlinks && randomLinksList()
GLOBAL_CONFIG.comment.enable && newestCommentInit()
if (PAGE_CONFIG.comment) {
initComment()
}
Expand All @@ -1022,7 +1043,10 @@ window.refreshFn = () => {
sco.initConsoleState()
if (document.getElementById('history-baidu')) sco.card_history() // 那年今日
if (document.getElementById('welcome-info')) sco.card_welcome() // 个性定位
if (GLOBAL_CONFIG.comment.type === "twikoo" && PAGE_CONFIG.comment) initializeCommentBarrage() // 热评
if (GLOBAL_CONFIG.comment.type === "twikoo" && PAGE_CONFIG.comment) {
initializeCommentBarrage() // 热评
GLOBAL_CONFIG.comment.enable && newestCommentInit()
}
}

sco.initTheme()
Expand Down

0 comments on commit 9cb94b6

Please sign in to comment.