Skip to content

Commit

Permalink
feat: preconnect 根據 CDN 配置引入
Browse files Browse the repository at this point in the history
feat: 移除 anchor 的 button, 直接點擊標題跳轉
feat: 更改 headline 的 hover 效果
improvement: tabs content 裏最後一個元素 margin-bottom 改為 0
fix: float 浮動佈局導致評論寬度異常的 bug
  • Loading branch information
jerryc127 committed Sep 22, 2023
1 parent deccde6 commit f9a2ad7
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 102 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/theme-butterfly-readme.png)

Demo: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [CrazyWong](https://blog.crazywong.com/)
📢 Demo: [Butterfly](https://butterfly.js.org/) || [CrazyWong](https://blog.crazywong.com/)

Docs: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)
📖 Docs: [English](https://butterfly.js.org/en/posts/butterfly-docs-en-get-started/) || [Chinese](https://butterfly.js.org/posts/21cfbf15/)

Based on [hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody) theme.

Expand Down
4 changes: 2 additions & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/theme-butterfly-readme.png)

預覽: 👍 [Butterfly](https://butterfly.js.org/) || 🤞 [CrazyWong](https://blog.crazywong.com/)
📢 預覽: [Butterfly](https://butterfly.js.org/) || [CrazyWong](https://blog.crazywong.com/)

文檔: 📖 [Butterfly Docs](https://butterfly.js.org/posts/21cfbf15/)
📖 文檔: [中文](https://butterfly.js.org/posts/21cfbf15/) || [English](https://butterfly.js.org/en/posts/butterfly-docs-en-get-started/)

一款基於[hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody)修改的主題

Expand Down
93 changes: 46 additions & 47 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,10 @@ index_post_content:

# anchor
anchor:
button:
enable: false
always_show: false
icon: # the unicode value of Font Awesome icon, such as '\3423'
auto_update: false # when you scroll in post, the URL will update according to header id.
# when you scroll, the URL will update according to header id.
auto_update: false
# Click the headline to scroll and update the anchor
click_to_scroll: false

# figcaption (圖片描述文字)
photofigcaption: false
Expand Down Expand Up @@ -933,58 +932,58 @@ CDN:
custom_format:

option:
# main_css:
# main:
# utils:
# translate:
# local_search:
# abcjs_basic_js:
# activate_power_mode:
# algolia_js:
# algolia_search:
# instantsearch:
# docsearch_js:
# docsearch_css:
# pjax:
# gitalk:
# gitalk_css:
# aplayer_css:
# aplayer_js:
# artalk_css:
# artalk_js:
# blueimp_md5:
# valine:
# busuanzi:
# canvas_fluttering_ribbon:
# canvas_nest:
# canvas_ribbon:
# click_heart:
# ClickShowText:
# disqusjs:
# disqusjs_css:
# twikoo:
# waline_js:
# waline_css:
# docsearch_css:
# docsearch_js:
# egjs_infinitegrid:
# fancybox:
# fancybox_css:
# fireworks:
# fontawesome:
# gitalk:
# gitalk_css:
# giscus:
# sharejs:
# sharejs_css:
# mathjax:
# instantpage:
# instantsearch:
# katex:
# katex_copytex:
# mermaid:
# canvas_ribbon:
# canvas_fluttering_ribbon:
# canvas_nest:
# lazyload:
# instantpage:
# typed:
# pangu:
# fancybox_css:
# fancybox:
# local_search:
# main:
# main_css:
# mathjax:
# medium_zoom:
# snackbar_css:
# snackbar:
# activate_power_mode:
# fireworks:
# click_heart:
# ClickShowText:
# fontawesome:
# egjs_infinitegrid:
# aplayer_css:
# aplayer_js:
# mermaid:
# meting_js:
# pangu:
# prismjs_autoloader:
# prismjs_js:
# prismjs_lineNumber_js:
# prismjs_autoloader:
# artalk_js:
# artalk_css:
# busuanzi:
# abcjs_basic_js:
# pjax:
# sharejs:
# sharejs_css:
# snackbar:
# snackbar_css:
# translate:
# twikoo:
# typed:
# utils:
# valine:
# waline_css:
# waline_js:
1 change: 0 additions & 1 deletion layout/includes/head.pug
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ if theme.blog_title_font && theme.blog_title_font.font_link
!=partial('includes/head/config', {}, {cache: true})

include ./head/config_site.pug
include ./head/noscript.pug

!=fragment_cache('injectHeadJs', function(){return inject_head_js()})

Expand Down
10 changes: 0 additions & 10 deletions layout/includes/head/noscript.pug

This file was deleted.

18 changes: 17 additions & 1 deletion layout/includes/head/preconnect.pug
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
link(rel="preconnect" href="//cdn.jsdelivr.net")
-
const { internal_provider, third_party_provider, custom_format } = theme.CDN
const providers = {
'jsdelivr': '//cdn.jsdelivr.net',
'cdnjs': '//cdnjs.cloudflare.com',
'unpkg': '//unpkg.com',
'custom': custom_format.match(/^((https?:)?(\/\/[^/]+)|([^/]+))(\/|$)/)[1]
}
-
if internal_provider === third_party_provider && internal_provider !== 'local'
link(rel="preconnect" href=providers[internal_provider])
else
if internal_provider !== 'local'
link(rel="preconnect" href=providers[internal_provider])
if third_party_provider !== 'local'
link(rel="preconnect" href=providers[third_party_provider])

if theme.google_analytics
link(rel="preconnect" href="//www.google-analytics.com" crossorigin='')
Expand Down
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-butterfly",
"version": "4.10.0-b1",
"version": "4.10.0-b2",
"description": "A Simple and Card UI Design theme for Hexo",
"main": "package.json",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions source/css/_global/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ body

if !hexo-config('copy.enable')
user-select: none
-webkit-user-select: none

// scrollbar - chrome/safari
*::-webkit-scrollbar
Expand Down
3 changes: 3 additions & 0 deletions source/css/_highlight/highlight.styl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ $code-block

&.copy-true
user-select: all
-webkit-user-select: all

& > table,
& > pre
Expand Down Expand Up @@ -128,6 +129,7 @@ $code-block
font-weight: bold
font-size: 1.15em
user-select: none
-webkit-user-select: none

.copy-notice
position: absolute
Expand All @@ -146,6 +148,7 @@ $code-block

.gutter
user-select: none
-webkit-user-select: none

.gist table
width: auto
Expand Down
1 change: 1 addition & 0 deletions source/css/_highlight/prismjs/line-number.styl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
font-size: 100%
pointer-events: none
user-select: none
-webkit-user-select: none

& > span
display: block
Expand Down
3 changes: 1 addition & 2 deletions source/css/_layout/aside.styl
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@
max-width: $toc-mobile-maxWidth
max-height: calc(100% - 60px)
width: $toc-mobile-width
transition: transform .3s
transition: none
transform: scale(0)
transform-origin: right bottom

&.open
transform: scale(1)
Expand Down
5 changes: 5 additions & 0 deletions source/css/_layout/comments.styl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
.comment-head
margin-bottom: 20px

&:after
display: block
clear: both
content: ''

.comment-headline
display: inline-block
vertical-align: middle
Expand Down
44 changes: 12 additions & 32 deletions source/css/_layout/post.styl
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
beautify()
headStyle(fontsize)
padding-left: unit(fontsize + 12, 'px')
padding-left: unit(fontsize + 8, 'px')

&:before
margin-left: unit((-(fontsize + 6)), 'px')
font-size: unit(fontsize, 'px')
font-size: unit(fontsize - 2, 'px')

&:hover
padding-left: unit(fontsize + 18, 'px')
padding-left: unit(fontsize + 12, 'px')

h1,
h2,
Expand All @@ -22,6 +21,7 @@ beautify()
top: calc(50% - 7px)
color: $title-prefix-icon-color
content: $title-prefix-icon
left: 0
line-height: 1
transition: all .2s ease-out
@extend .fontawesomeIcon
Expand Down Expand Up @@ -106,35 +106,15 @@ beautify()
font-family: Monaco, 'Ubuntu Mono', monospace
line-height: 1em

if hexo-config('anchor.button.enable')
if hexo-config('anchor.click_to_scroll')
a.headerlink
&:after
@extend .fontawesomeIcon
float: right
color: var(--headline-presudo)
content: $archor-button-icon
font-size: .95em
transition: all .3s

&:hover
&:after
color: var(--pseudo-hover)

if !hexo-config('anchor.button.always_show')
a.headerlink
&:after
opacity: 0

h1,
h2,
h3,
h4,
h5,
h6
&:hover
a.headerlink
&:after
opacity: 1
position: absolute
top: 0
right: 0
left 0
bottom: 0
width 100%
height: 100%

ol,
ul
Expand Down
3 changes: 3 additions & 0 deletions source/css/_tags/tabs.styl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
display: block
animation: tabshow .5s

> :last-child
margin-bottom: 0

> .tab-to-top
padding: 0 16px 10px 0
width: 100%
Expand Down
2 changes: 0 additions & 2 deletions source/css/var.styl
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,3 @@ $tab-to-top-color = #99a9bf
$tab-to-top-hover-color = $theme-color
// Tag Plugins - timeline
$timeline-default-color = $theme-color
// archor
$archor-button-icon = hexo-config('anchor.button.icon') ? hexo-config('anchor.button.icon') : '\f0c1'
11 changes: 9 additions & 2 deletions source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,15 @@ document.addEventListener('DOMContentLoaded', function () {
saveToLocal.set('aside-status', saveStatus, 2)
$htmlDom.toggle('hide-aside')
},
'mobile-toc-button': () => { // Show mobile toc
document.getElementById('card-toc').classList.toggle('open')
'mobile-toc-button': item => { // Show mobile toc
const tocEle = document.getElementById('card-toc')
tocEle.style.transformOrigin = `right ${item.getBoundingClientRect().top + 17}px`
tocEle.style.transition = 'transform 0.3s ease-in-out'
tocEle.classList.toggle('open')
tocEle.addEventListener('transitionend', () => {
tocEle.style.transition = ''
tocEle.style.transformOrigin = ''
}, { once: true })
},
'chat-btn': () => { // Show chat
window.chatBtnFn()
Expand Down

0 comments on commit f9a2ad7

Please sign in to comment.