Skip to content

Commit

Permalink
Merge pull request #296 from XPoet/dev
Browse files Browse the repository at this point in the history
release
  • Loading branch information
XPoet authored Jan 2, 2024
2 parents 2558dd4 + 812dfbf commit 4a44cdc
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ lazyload:
# ---------------------------------------------------------------------------------------
cdn:
enable: false # Option values: true | false
provider: jsdelivr # Option values: jsdelivr | unpkg
provider: cdnjs # Option values: cdnjs | jsdelivr | unpkg


# ---------------------------------------------------------------------------------------
Expand Down
7 changes: 3 additions & 4 deletions layout/_partial/post/post-meta-info.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ const home_tag_limit_number = 5

<% if (page_type === 'post') { %>
<span class="meta-info-item post-create-date">
<i class="icon fa-solid fa-calendar-check"></i>&nbsp;
<span class="pc"><%= date(post.date, theme.post?.datetime_format || 'YYYY-MM-DD HH:mm:ss') %></span>
<span class="mobile"><%= date(post.date, 'YYYY-MM-DD HH:mm') %></span>
<i class="icon fa-solid fa-calendar-plus"></i>&nbsp;
<span class="datetime"><%= date(post.date, theme.post?.datetime_format || 'YYYY-MM-DD HH:mm:ss') %></span>
</span>
<span class="meta-info-item post-update-date">
<i class="icon fa-solid fa-file-pen"></i>&nbsp;
<span class="pc" data-updated="<%= post.updated %>"><%= date(post.updated, theme.post?.datetime_format || 'YYYY-MM-DD HH:mm:ss') %></span>
<span class="datetime" data-updated="<%= post.updated %>"><%= date(post.updated, theme.post?.datetime_format || 'YYYY-MM-DD HH:mm:ss') %></span>
</span>
<% } %>
Expand Down
25 changes: 22 additions & 3 deletions scripts/helpers/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,44 @@ hexo.extend.helper.register('getAuthorBadge', function (postCount, authorLabelCo
const getSourceCdnUrl = (tyle, themeConfig, path) => {
const version = require('../../package.json').version
let { provider } = themeConfig?.cdn || {}
const providerEnum = {
jsdelivr: 'jsdelivr',
unpkg: 'unpkg',
cdnjs: 'cdnjs'
}

if (!provider) {
provider = 'jsdelivr'
provider = providerEnum.cdnjs
}

let urlPrefix = ''

switch (provider?.toLocaleLowerCase()) {
case 'jsdelivr':
case providerEnum.jsdelivr:
urlPrefix = '//cdn.jsdelivr.net/npm/hexo-theme-keep'
if (tyle === 'js') {
return `<script src="${urlPrefix}@${version}/source/${path}"></script>`
} else {
return `<link rel="stylesheet" href="${urlPrefix}@${version}/source/${path}">`
}
case 'unpkg':

case providerEnum.unpkg:
urlPrefix = '//unpkg.com/hexo-theme-keep'
if (tyle === 'js') {
return `<script src="${urlPrefix}@${version}/source/${path}"></script>`
} else {
return `<link rel="stylesheet" href="${urlPrefix}@${version}/source/${path}">`
}

case providerEnum.cdnjs:
urlPrefix = 'https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-keep'
if (tyle === 'js') {
path = path.includes('.min.js') ? path : path.replace('.js', '.min.js')
return `<script src="${urlPrefix}/${version}/${path}"></script>`
} else {
path = path.includes('.min.css') ? path : path.replace('.css', '.min.css')
return `<link rel="stylesheet" href="${urlPrefix}/${version}/${path}">`
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/css/common/code-block/code-block.styl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ figure.highlight {
font-weight 600
font-size 1rem
font-family 'Font Awesome 6 Free'
content '\f078'
content '\f103'
}

&:hover {
Expand Down
18 changes: 0 additions & 18 deletions source/css/layout/_partial/post-meta-info.styl
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,11 @@ $meta-icon-interspace = 0.4rem

.post-create-date {
display var(--post-create-datetime)

.mobile {
display none
}

+keep-tablet() {
.pc {
display none
}

.mobile {
display inline-block
}
}
}


.post-update-date {
display var(--post-update-datetime)

+keep-tablet() {
display none
}
}


Expand Down
2 changes: 1 addition & 1 deletion source/js/post/post-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function initPostHelper() {

resetPostUpdateDate() {
const updateDateDom = document.querySelector(
'.post-meta-info-container .post-update-date .pc'
'.post-meta-info-container .post-update-date .datetime'
)
const updated = new Date(updateDateDom.dataset.updated).getTime()
const format = KEEP.theme_config.post?.datetime_format || 'YYYY-MM-DD HH:mm:ss'
Expand Down
10 changes: 5 additions & 5 deletions source/js/toggle-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ KEEP.initModeToggle = () => {
iconDom: document.querySelector('.tool-toggle-theme-mode i'),

enableLightMode() {
document.body.classList.remove('dark-mode')
document.body.classList.add('light-mode')
document.documentElement.classList.remove('dark-mode')
document.documentElement.classList.add('light-mode')
this.iconDom.className = 'fas fa-moon'
KEEP.themeInfo.styleStatus.isDark = false
KEEP.setStyleStatus()
},

enableDarkMode() {
document.body.classList.add('dark-mode')
document.body.classList.remove('light-mode')
document.documentElement.classList.add('dark-mode')
document.documentElement.classList.remove('light-mode')
this.iconDom.className = 'fas fa-sun'
KEEP.themeInfo.styleStatus.isDark = true
KEEP.setStyleStatus()
Expand All @@ -37,7 +37,7 @@ KEEP.initModeToggle = () => {

initModeToggleButton() {
this.themeModeToggleBtn.addEventListener('click', () => {
const isDark = document.body.classList.contains('dark-mode')
const isDark = document.documentElement.classList.contains('dark-mode')
isDark ? this.enableLightMode() : this.enableDarkMode()
})
},
Expand Down

0 comments on commit 4a44cdc

Please sign in to comment.