mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2025-09-15 12:58:48 +08:00
feature: 增加 tags 標簽外掛 - label
improvement: 優化 pjax 下 404 頁面
This commit is contained in:
parent
597f0d2019
commit
aa7173fc69
@ -1,28 +0,0 @@
|
|||||||
- var top_img = theme.error_404.background || theme.default_top_img
|
|
||||||
- var bg_img = `background-image: url('${url_for(top_img)}')`
|
|
||||||
|
|
||||||
doctype html
|
|
||||||
html(lang=config.language data-theme=theme.display_mode)
|
|
||||||
head
|
|
||||||
include includes/head.pug
|
|
||||||
body
|
|
||||||
if theme.preloader
|
|
||||||
!=partial('includes/loading/loading', {}, {cache: true})
|
|
||||||
|
|
||||||
if theme.fireworks && theme.fireworks.enable
|
|
||||||
canvas.fireworks
|
|
||||||
|
|
||||||
if theme.background
|
|
||||||
#web_bg
|
|
||||||
|
|
||||||
#error-wrap
|
|
||||||
.error-content
|
|
||||||
.error-img(style=bg_img)
|
|
||||||
.error-info
|
|
||||||
h1.error_title= '404'
|
|
||||||
.error_subtitle= theme.error_404.subtitle
|
|
||||||
a.button--animated(href=config.root)
|
|
||||||
i.fas.fa-rocket
|
|
||||||
= _p('error404.back_button')
|
|
||||||
|
|
||||||
include includes/additional-js.pug
|
|
||||||
17
layout/includes/404.pug
Normal file
17
layout/includes/404.pug
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
- var top_img = theme.error_404.background || theme.default_top_img
|
||||||
|
- var bg_img = `background-image: url('${url_for(top_img)}')`
|
||||||
|
|
||||||
|
#body-wrap.error
|
||||||
|
div(style='display: none')
|
||||||
|
include ./header/index.pug
|
||||||
|
|
||||||
|
#error-wrap
|
||||||
|
.error-content
|
||||||
|
.error-img(style=bg_img)
|
||||||
|
.error-info
|
||||||
|
h1.error_title= '404'
|
||||||
|
.error_subtitle= theme.error_404.subtitle
|
||||||
|
a.button--animated(href=config.root)
|
||||||
|
i.fas.fa-rocket
|
||||||
|
= _p('error404.back_button')
|
||||||
|
|
||||||
@ -8,12 +8,12 @@
|
|||||||
var showToc = is_post() && theme.aside.enable && pageToc && (toc(page.content) !== '' || page.encrypt == true )
|
var showToc = is_post() && theme.aside.enable && pageToc && (toc(page.content) !== '' || page.encrypt == true )
|
||||||
-
|
-
|
||||||
|
|
||||||
script#config-diff
|
script#config-diff.
|
||||||
.
|
var GLOBAL_CONFIG_SITE = {
|
||||||
var GLOBAL_CONFIG_SITE = {
|
title: '!{pageTitle}',
|
||||||
isPost: !{is_post()},
|
isPost: !{is_post()},
|
||||||
isHome: !{is_home()},
|
isHome: !{is_home()},
|
||||||
isHighlightShrink: !{isHighlightShrink},
|
isHighlightShrink: !{isHighlightShrink},
|
||||||
isToc: !{showToc},
|
isToc: !{showToc},
|
||||||
postUpdate: '!{full_date(page.updated)}'
|
postUpdate: '!{full_date(page.updated)}'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,28 +15,32 @@ html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside
|
|||||||
|
|
||||||
!=partial('includes/sidebar', {}, {cache: true})
|
!=partial('includes/sidebar', {}, {cache: true})
|
||||||
|
|
||||||
#body-wrap(class=pageType)
|
if page.type !== '404'
|
||||||
include ./header/index.pug
|
#body-wrap(class=pageType)
|
||||||
|
include ./header/index.pug
|
||||||
|
|
||||||
main#content-inner.layout(class=hideAside)
|
main#content-inner.layout(class=hideAside)
|
||||||
if body
|
if body
|
||||||
div!= body
|
div!= body
|
||||||
|
else
|
||||||
|
block content
|
||||||
|
if theme.aside.enable && page.aside !== false
|
||||||
|
include widget/index.pug
|
||||||
|
|
||||||
|
- var footerBg = theme.footer_bg
|
||||||
|
if (footerBg)
|
||||||
|
if (footerBg === true)
|
||||||
|
- var footer_bg = bg_img
|
||||||
|
else
|
||||||
|
- var footer_bg = theme.footer_bg.indexOf('/') !== -1 ? `background-image: url('${url_for(footerBg)}')` : `background: ${footerBg}`
|
||||||
else
|
else
|
||||||
block content
|
- var footer_bg = ''
|
||||||
if theme.aside.enable && page.aside !== false
|
|
||||||
include widget/index.pug
|
|
||||||
|
|
||||||
- var footerBg = theme.footer_bg
|
footer#footer(style=footer_bg)
|
||||||
if (footerBg)
|
!=partial('includes/footer', {}, {cache: true})
|
||||||
if (footerBg === true)
|
|
||||||
- var footer_bg = bg_img
|
|
||||||
else
|
|
||||||
- var footer_bg = theme.footer_bg.indexOf('/') !== -1 ? `background-image: url('${url_for(footerBg)}')` : `background: ${footerBg}`
|
|
||||||
else
|
|
||||||
- var footer_bg = ''
|
|
||||||
|
|
||||||
footer#footer(style=footer_bg)
|
else
|
||||||
!=partial('includes/footer', {}, {cache: true})
|
include ./404.pug
|
||||||
|
|
||||||
include ./rightside.pug
|
include ./rightside.pug
|
||||||
!=partial('includes/third-party/search/index', {}, {cache: true})
|
!=partial('includes/third-party/search/index', {}, {cache: true})
|
||||||
|
|||||||
4
layout/includes/third-party/pjax.pug
vendored
4
layout/includes/third-party/pjax.pug
vendored
@ -86,10 +86,6 @@ script.
|
|||||||
|
|
||||||
document.addEventListener('pjax:error', (e) => {
|
document.addEventListener('pjax:error', (e) => {
|
||||||
if (e.request.status === 404) {
|
if (e.request.status === 404) {
|
||||||
if (!{theme.anchor}) {
|
|
||||||
location.hash && e.request.responseURL !== location.href ? pjax.loadUrl(location.href) : pjax.loadUrl('/404.html')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
pjax.loadUrl('/404.html')
|
pjax.loadUrl('/404.html')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hexo-theme-butterfly",
|
"name": "hexo-theme-butterfly",
|
||||||
"version": "3.7.5-b4",
|
"version": "3.7.5-b5",
|
||||||
"description": "A Simple and Card UI Design theme for Hexo",
|
"description": "A Simple and Card UI Design theme for Hexo",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -9,7 +9,10 @@ hexo.extend.generator.register('404', function (locals) {
|
|||||||
if (!hexo.theme.config.error_404.enable) return
|
if (!hexo.theme.config.error_404.enable) return
|
||||||
return {
|
return {
|
||||||
path: '404.html',
|
path: '404.html',
|
||||||
data: locals.posts,
|
layout: ['page'],
|
||||||
layout: ['404']
|
data: {
|
||||||
|
type: '404',
|
||||||
|
top_img: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
16
scripts/tag/label.js
Normal file
16
scripts/tag/label.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* Butterfly
|
||||||
|
* label
|
||||||
|
* {% label text color %}
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
function addLabel (args, content) {
|
||||||
|
const text = args[0]
|
||||||
|
const className = args[1] || 'default'
|
||||||
|
|
||||||
|
return `<mark class="hl-label ${className}">${text}</mark> `
|
||||||
|
}
|
||||||
|
|
||||||
|
hexo.extend.tag.register('label', addLabel, { ends: false })
|
||||||
@ -91,6 +91,7 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
|
|||||||
.hide-button,
|
.hide-button,
|
||||||
.btn-beautify,
|
.btn-beautify,
|
||||||
.mermaid,
|
.mermaid,
|
||||||
|
.hl-label,
|
||||||
.post-outdate-notice,
|
.post-outdate-notice,
|
||||||
.error-img,
|
.error-img,
|
||||||
#article-container iframe,
|
#article-container iframe,
|
||||||
|
|||||||
@ -173,24 +173,15 @@ if hexo-config('readmode')
|
|||||||
border: 1px solid var(--gray) !important
|
border: 1px solid var(--gray) !important
|
||||||
|
|
||||||
.hide-button,
|
.hide-button,
|
||||||
.btn-beautify
|
.btn-beautify,
|
||||||
|
.hl-label
|
||||||
|
border: 1px solid var(--gray) !important
|
||||||
background: var(--readmode-light-color) !important
|
background: var(--readmode-light-color) !important
|
||||||
color: var(--font-color) !important
|
color: var(--font-color) !important
|
||||||
|
|
||||||
.btn-beautify
|
|
||||||
border: 1px solid var(--gray) !important
|
|
||||||
|
|
||||||
.button--animated:before
|
.button--animated:before
|
||||||
background: var(--readmode-light-color) !important
|
background: var(--readmode-light-color) !important
|
||||||
|
|
||||||
.hide-inline,
|
|
||||||
.hide-block
|
|
||||||
& >.hide-button
|
|
||||||
border: 1px solid var(--gray)
|
|
||||||
|
|
||||||
& > .button--animated:before
|
|
||||||
background: var(--readmode-light-color)
|
|
||||||
|
|
||||||
.note
|
.note
|
||||||
border: 2px solid var(--gray)
|
border: 2px solid var(--gray)
|
||||||
border-left-color: var(--gray) !important
|
border-left-color: var(--gray) !important
|
||||||
|
|||||||
11
source/css/_tags/label.styl
Normal file
11
source/css/_tags/label.styl
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.hl-label
|
||||||
|
padding: 2px 4px
|
||||||
|
border-radius: 3px
|
||||||
|
color: $btn-color
|
||||||
|
|
||||||
|
&.default
|
||||||
|
background-color: $btn-default-color
|
||||||
|
|
||||||
|
for $type in $tagsP-types
|
||||||
|
&.{$type}
|
||||||
|
background-color: lookup('$tagsP-' + $type + '-color')
|
||||||
@ -413,7 +413,11 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const updateAnchor = function (anchor) {
|
const updateAnchor = function (anchor) {
|
||||||
if (window.history.replaceState && anchor !== window.location.hash) {
|
if (window.history.replaceState && anchor !== window.location.hash) {
|
||||||
if (!anchor) anchor = location.pathname
|
if (!anchor) anchor = location.pathname
|
||||||
window.history.replaceState({}, '', anchor)
|
const title = GLOBAL_CONFIG_SITE.title
|
||||||
|
window.history.replaceState({
|
||||||
|
url: location.href,
|
||||||
|
title: title
|
||||||
|
}, title, anchor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user