[opt] banner
This commit is contained in:
parent
e04a7887f0
commit
cb717580a0
|
@ -23,7 +23,7 @@ open_graph:
|
||||||
logo:
|
logo:
|
||||||
avatar: '[${config.avatar}](/about/)' # you can set avatar link in _config.yml or '[https://xxx.png](/about/)'
|
avatar: '[${config.avatar}](/about/)' # you can set avatar link in _config.yml or '[https://xxx.png](/about/)'
|
||||||
title: '[${config.title}](/)' # you can set html tag like: '[<img no-lazy height="32px" src="xxx"/>](/)'
|
title: '[${config.title}](/)' # you can set html tag like: '[<img no-lazy height="32px" src="xxx"/>](/)'
|
||||||
subtitle: '' # '文字1 | 文字2' (鼠标放上去会切换到文字2)
|
subtitle: '${config.subtitle}' # '文字1 | 文字2' (鼠标放上去会切换到文字2)
|
||||||
|
|
||||||
# 侧边栏主功能导航菜单
|
# 侧边栏主功能导航菜单
|
||||||
menubar:
|
menubar:
|
||||||
|
@ -63,7 +63,7 @@ site_tree:
|
||||||
# 主页配置
|
# 主页配置
|
||||||
home:
|
home:
|
||||||
leftbar: welcome, recent
|
leftbar: welcome, recent
|
||||||
rightbar: # timeline
|
rightbar: welcome
|
||||||
# 博客列表页配置
|
# 博客列表页配置
|
||||||
index_blog:
|
index_blog:
|
||||||
base_dir: blog # 只影响自动生成的页面路径
|
base_dir: blog # 只影响自动生成的页面路径
|
||||||
|
@ -191,7 +191,7 @@ comments:
|
||||||
data-input-position: top # top, bottom
|
data-input-position: top # top, bottom
|
||||||
data-theme: preferred_color_scheme
|
data-theme: preferred_color_scheme
|
||||||
data-lang: zh-CN
|
data-lang: zh-CN
|
||||||
data-loading: lazy
|
data-loading: # lazy
|
||||||
crossorigin: anonymous
|
crossorigin: anonymous
|
||||||
|
|
||||||
# Twikoo
|
# Twikoo
|
||||||
|
|
|
@ -1,30 +1,90 @@
|
||||||
<%
|
<%
|
||||||
|
|
||||||
var banner_url
|
var banner = {}
|
||||||
|
|
||||||
if (page.banner) {
|
if (page.banner) {
|
||||||
banner_url = page.banner
|
banner.url = page.banner
|
||||||
} else if (theme.topic.tree[page.topic]?.banner != null) {
|
} else if (theme.topic.tree[page.topic]?.banner != null) {
|
||||||
banner_url = theme.topic.tree[page.topic]?.banner
|
banner.url = theme.topic.tree[page.topic]?.banner
|
||||||
} else if (theme.wiki.tree[page.wiki]?.banner != null) {
|
} else if (theme.wiki.tree[page.wiki]?.banner != null) {
|
||||||
banner_url = theme.wiki.tree[page.wiki]?.banner
|
banner.url = theme.wiki.tree[page.wiki]?.banner
|
||||||
|
}
|
||||||
|
banner = Object.assign(banner, page.banner_info)
|
||||||
|
// 标题
|
||||||
|
if (banner.title == null) {
|
||||||
|
banner.title = page.h1 != null ? page.h1 : page.title
|
||||||
|
}
|
||||||
|
|
||||||
|
function layoutBreadcrumb() {
|
||||||
|
if (page.breadcrumb === false) {
|
||||||
|
return `<div class="top"></div>`
|
||||||
|
}
|
||||||
|
var el = ''
|
||||||
|
// 1.main
|
||||||
|
el += `<div class="top bread-nav footnote">`
|
||||||
|
// 2.left
|
||||||
|
el += `<div class="left">`
|
||||||
|
// 3.left.top: 面包屑导航
|
||||||
|
el += `<div class="flex-row" id="breadcrumb">`
|
||||||
|
// 首页
|
||||||
|
el += `<a class="cap breadcrumb" href="${url_for(config.root)}">${__("btn.home")}</a>`
|
||||||
|
if (theme.wiki.tree[page.wiki]) {
|
||||||
|
el += partial('breadcrumb/wiki')
|
||||||
|
} else if (page.layout == 'post') {
|
||||||
|
el += partial('breadcrumb/blog')
|
||||||
|
} else {
|
||||||
|
el += partial('breadcrumb/page')
|
||||||
|
}
|
||||||
|
// end 3.left.top
|
||||||
|
el += `</div>`
|
||||||
|
// 3.left.bottom
|
||||||
|
el += partial('dateinfo')
|
||||||
|
// end 2.left
|
||||||
|
el += `</div>`
|
||||||
|
// end 1.main
|
||||||
|
el += `</div>`
|
||||||
|
return el
|
||||||
}
|
}
|
||||||
|
|
||||||
function layoutTitle() {
|
function layoutTitle() {
|
||||||
const title = page.h1 != null ? page.h1 : page.title
|
if (banner.title?.length > 0) {
|
||||||
if (title && title.length > 0) {
|
return `<h1 class="text title"><span>${banner.title}</span></h1>`
|
||||||
return `<h1 class="text title"><span>${title}</span></h1>`
|
} else {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function layoutSubtitle() {
|
||||||
|
if (banner.subtitle?.length > 0) {
|
||||||
|
return `<div class="text subtitle">${banner.subtitle}</div>`
|
||||||
|
} else {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function layoutIcon() {
|
||||||
|
if (banner.avatar?.length > 0 || banner.icon?.length > 0) {
|
||||||
|
return `<img class="avatar" src="${banner.avatar || banner.icon}">`
|
||||||
} else {
|
} else {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function layoutBottom() {
|
function layoutBottom() {
|
||||||
const article_title = layoutTitle()
|
const el_icon = layoutIcon()
|
||||||
if (article_title.length > 0) {
|
const el_title = layoutTitle()
|
||||||
|
const el_subtitle = layoutSubtitle()
|
||||||
|
var cls = ''
|
||||||
|
if (el_title.length > 0 && el_subtitle.length == 0) {
|
||||||
|
cls += ' only-title'
|
||||||
|
}
|
||||||
|
if (el_title.length > 0) {
|
||||||
return `
|
return `
|
||||||
<div class="bottom">
|
<div class="bottom${cls}">
|
||||||
|
${el_icon}
|
||||||
<div class="text-area">
|
<div class="text-area">
|
||||||
${article_title}
|
${el_title}
|
||||||
|
${el_subtitle}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
@ -34,18 +94,18 @@ function layoutBottom() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function layoutDiv() {
|
function layoutDiv() {
|
||||||
const top = partial('article_top_area')
|
|
||||||
const bottom = layoutBottom()
|
const bottom = layoutBottom()
|
||||||
if (top.trim().length == 0 && bottom.length == 0) {
|
if (page.breadcrumb === false && bottom.length == 0) {
|
||||||
return ``
|
return ``
|
||||||
}
|
}
|
||||||
|
const top = layoutBreadcrumb()
|
||||||
var style = ``
|
var style = ``
|
||||||
var el = ``
|
var el = ``
|
||||||
el += `<div class="article banner top">`
|
el += `<div class="article banner top">`
|
||||||
if (banner_url?.length > 0) {
|
if (banner.url?.length > 0) {
|
||||||
el += `<img class="bg" src="${banner_url}">`
|
el += `<img class="bg" src="${banner.url}">`
|
||||||
if (page.poster?.color) {
|
if (banner.color) {
|
||||||
style += ' style="--text-banner:' + page.poster?.color + '"'
|
style += ' style="--text-banner:' + banner.color + '"'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
el += `
|
el += `
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
<%
|
|
||||||
function layoutDiv() {
|
|
||||||
if (page.breadcrumb === false) {
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
var el = ''
|
|
||||||
// 1.main
|
|
||||||
el += `<div class="top bread-nav footnote">`
|
|
||||||
// 2.left
|
|
||||||
el += `<div class="left">`
|
|
||||||
// 3.left.top: 面包屑导航
|
|
||||||
el += `<div class="flex-row" id="breadcrumb">`
|
|
||||||
// 首页
|
|
||||||
el += `<a class="cap breadcrumb" href="${url_for(config.root)}">${__("btn.home")}</a>`
|
|
||||||
if (theme.wiki.tree[page.wiki]) {
|
|
||||||
el += partial('breadcrumb/wiki')
|
|
||||||
} else if (page.layout == 'post') {
|
|
||||||
el += partial('breadcrumb/blog')
|
|
||||||
} else {
|
|
||||||
el += partial('breadcrumb/page')
|
|
||||||
}
|
|
||||||
// end 3.left.top
|
|
||||||
el += `</div>`
|
|
||||||
// 3.left.bottom
|
|
||||||
el += partial('dateinfo')
|
|
||||||
// end 2.left
|
|
||||||
el += `</div>`
|
|
||||||
// end 1.main
|
|
||||||
el += `</div>`
|
|
||||||
return el
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%- layoutDiv() %>
|
|
|
@ -1,29 +0,0 @@
|
||||||
<%
|
|
||||||
function layoutDiv() {
|
|
||||||
const author = page.author
|
|
||||||
var el = ``
|
|
||||||
el += `<div class="banner author top">`
|
|
||||||
if (author.banner) {
|
|
||||||
el += `<img class="bg" src="${author.banner}">`
|
|
||||||
}
|
|
||||||
el += `
|
|
||||||
<div class="content">
|
|
||||||
<div class="top">
|
|
||||||
<button class="back cap" onclick="window.history.back()">
|
|
||||||
${icon('default:goback')}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="bottom">
|
|
||||||
<img class="avatar" src="${author.avatar}">
|
|
||||||
<div class="text-area">
|
|
||||||
<p class="text title">${author.name}</p>
|
|
||||||
<div class="text subtitle">${author.description || ""}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
el += `</div>`
|
|
||||||
return el
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%- layoutDiv() %>
|
|
|
@ -67,7 +67,7 @@ function layoutDiv() {
|
||||||
const main = md_text(logo.title)
|
const main = md_text(logo.title)
|
||||||
if (main) {
|
if (main) {
|
||||||
let url = md_link(logo.title)
|
let url = md_link(logo.title)
|
||||||
el += layoutTitle(main, url, logo.subtitle)
|
el += layoutTitle(main, url, md_text(logo.subtitle))
|
||||||
}
|
}
|
||||||
el += `</div>`
|
el += `</div>`
|
||||||
el += '</header>'
|
el += '</header>'
|
||||||
|
|
|
@ -8,14 +8,21 @@ if (page.author) {
|
||||||
}
|
}
|
||||||
function layoutArchiveList() {
|
function layoutArchiveList() {
|
||||||
var el = ''
|
var el = ''
|
||||||
|
var cls = ''
|
||||||
if (page.author) {
|
if (page.author) {
|
||||||
page.title = page.author.name
|
page.title = page.author.name
|
||||||
el += partial('_partial/main/navbar/author_banner')
|
page.banner = page.author.banner
|
||||||
|
page.banner_info = {
|
||||||
|
avatar: page.author.avatar,
|
||||||
|
subtitle: page.author.description
|
||||||
|
}
|
||||||
|
el += partial('_partial/main/navbar/article_banner')
|
||||||
|
cls += ' author'
|
||||||
} else {
|
} else {
|
||||||
page.title = __('btn.archives')
|
page.title = __('btn.archives')
|
||||||
el += partial('_partial/main/navbar/nav_tabs_blog')
|
el += partial('_partial/main/navbar/nav_tabs_blog')
|
||||||
}
|
}
|
||||||
el += `<div class="post-list archives">`
|
el += `<div class="post-list${cls} archives">`
|
||||||
var years = []
|
var years = []
|
||||||
const posts = page.author != null ? site.posts.filter(p => (p.author || theme.default_author.id) == page.author.id) : site.posts
|
const posts = page.author != null ? site.posts.filter(p => (p.author || theme.default_author.id) == page.author.id) : site.posts
|
||||||
posts.sort('date', -1).each(function(post) {
|
posts.sort('date', -1).each(function(post) {
|
||||||
|
|
|
@ -9,17 +9,18 @@ hexo.extend.helper.register('md_text', function(args) {
|
||||||
if (args == undefined) {
|
if (args == undefined) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
const { config } = hexo
|
||||||
|
args = args.replace('${config.title}', config.title)
|
||||||
|
args = args.replace('${config.subtitle}', config.subtitle)
|
||||||
|
args = args.replace('${config.avatar}', config.avatar)
|
||||||
let tmp = args.split('](')
|
let tmp = args.split('](')
|
||||||
if (tmp.length > 1) {
|
if (tmp.length > 1) {
|
||||||
tmp = tmp[0]
|
tmp = tmp[0]
|
||||||
if (tmp.length > 1) {
|
if (tmp.length > 1) {
|
||||||
tmp = tmp.substring(1, tmp.length)
|
tmp = tmp.substring(1, tmp.length)
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if (tmp == 'config.title' || tmp == '${config.title}') {
|
tmp = args
|
||||||
tmp = hexo.config.title
|
|
||||||
} else if (tmp == 'config.avatar' || tmp == '${config.avatar}') {
|
|
||||||
tmp = hexo.config.avatar
|
|
||||||
}
|
}
|
||||||
return tmp
|
return tmp
|
||||||
})
|
})
|
||||||
|
|
|
@ -48,7 +48,7 @@ $fs-body = convert(hexo-config('style.font-size.body'))
|
||||||
$fs-code = convert(hexo-config('style.font-size.code'))
|
$fs-code = convert(hexo-config('style.font-size.code'))
|
||||||
$fs-codeblock = convert(hexo-config('style.font-size.codeblock'))
|
$fs-codeblock = convert(hexo-config('style.font-size.codeblock'))
|
||||||
|
|
||||||
$fsh1 = 'calc(%s + 11px)' % $fs-body
|
$fsh1 = 'calc(%s + 9px)' % $fs-body
|
||||||
$fsh2 = 'calc(%s + 11px)' % $fs-body
|
$fsh2 = 'calc(%s + 11px)' % $fs-body
|
||||||
$fsh3 = 'calc(%s + 7px)' % $fs-body
|
$fsh3 = 'calc(%s + 7px)' % $fs-body
|
||||||
$fsh4 = 'calc(%s + 4px)' % $fs-body
|
$fsh4 = 'calc(%s + 4px)' % $fs-body
|
||||||
|
|
|
@ -4,7 +4,7 @@ $device-mobile-425 = 425px
|
||||||
$device-mobile = 500px
|
$device-mobile = 500px
|
||||||
$device-mobile-max = 667px
|
$device-mobile-max = 667px
|
||||||
$device-tablet = 768px
|
$device-tablet = 768px
|
||||||
$device-laptop = 1024px
|
$device-laptop = 1180px
|
||||||
$device-desktop = 1440px
|
$device-desktop = 1440px
|
||||||
$device-2k = 2048px
|
$device-2k = 2048px
|
||||||
$device-4k = 2560px
|
$device-4k = 2560px
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
.l_body .l_left
|
.l_body .l_left
|
||||||
top: 8px
|
top: 8px
|
||||||
.l_body .l_right
|
.l_body .l_right
|
||||||
|
width: calc(var(--width-sidebar) - var(--gap-max) + var(--gap-padding))
|
||||||
.widgets
|
.widgets
|
||||||
height: 100%
|
height: 100%
|
||||||
overflow visible
|
overflow visible
|
||||||
|
@ -37,6 +38,7 @@
|
||||||
background: var(--site-bg)
|
background: var(--site-bg)
|
||||||
overflow: auto
|
overflow: auto
|
||||||
scrollbar(0, 0)
|
scrollbar(0, 0)
|
||||||
|
--blur-bg: var(--alpha75)
|
||||||
.l_body[rightbar]
|
.l_body[rightbar]
|
||||||
.l_right
|
.l_right
|
||||||
transform: translateX(0px)
|
transform: translateX(0px)
|
||||||
|
@ -76,7 +78,7 @@
|
||||||
left: 0
|
left: 0
|
||||||
width: 100%
|
width: 100%
|
||||||
height: 100%
|
height: 100%
|
||||||
background: rgba(black, 0.2)
|
background: rgba(black, 0.1)
|
||||||
z-index: 9
|
z-index: 9
|
||||||
opacity 0
|
opacity 0
|
||||||
trans1 opacity
|
trans1 opacity
|
|
@ -100,3 +100,6 @@
|
||||||
opacity: 1
|
opacity: 1
|
||||||
color: var(--text)
|
color: var(--text)
|
||||||
background: var(--block-hover)
|
background: var(--block-hover)
|
||||||
|
|
||||||
|
.post-list.author #archive
|
||||||
|
padding: 1rem 0
|
|
@ -17,13 +17,14 @@
|
||||||
.title
|
.title
|
||||||
font-size: $fsh1
|
font-size: $fsh1
|
||||||
color: var(--text-banner)
|
color: var(--text-banner)
|
||||||
.bottom
|
|
||||||
padding: 2rem 1rem
|
|
||||||
h1
|
h1
|
||||||
line-height: 1.2
|
line-height: 1.2
|
||||||
margin: 0
|
margin: 0.25rem 0
|
||||||
|
|
||||||
.l_body[text-indent] .article.banner .content .bottom
|
.l_body .article.banner .content .bottom.only-title .title
|
||||||
|
padding: 0.75rem 0
|
||||||
|
|
||||||
|
.l_body[text-indent] .article.banner .content .bottom.only-title
|
||||||
justify-content: center
|
justify-content: center
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -127,13 +127,6 @@
|
||||||
.tag-plugin.banner .navbar a.active
|
.tag-plugin.banner .navbar a.active
|
||||||
blur-effect()
|
blur-effect()
|
||||||
|
|
||||||
@media screen and (min-width: $device-mobile-max)
|
|
||||||
.banner.author.top
|
|
||||||
margin-left: var(--gap-max)
|
|
||||||
margin-right: var(--gap-max)
|
|
||||||
|
|
||||||
@media screen and (max-width: $device-mobile-max)
|
@media screen and (max-width: $device-mobile-max)
|
||||||
.banner.top
|
.banner.top
|
||||||
border-radius: 0
|
border-radius: 0
|
||||||
.md-text.content:first-child .tag-plugin.banner:first-child
|
|
||||||
margin-top: 1rem
|
|
|
@ -1,5 +1,4 @@
|
||||||
.widget-wrapper.post-list .widget-body
|
.widget-wrapper.post-list .widget-body
|
||||||
margin-top: 0.25rem
|
|
||||||
a
|
a
|
||||||
line-height: 1
|
line-height: 1
|
||||||
font-size: $fs-14
|
font-size: $fs-14
|
||||||
|
|
Loading…
Reference in New Issue