hexo-theme-stellar/layout/_partial/main/navbar/article_banner.ejs

61 lines
1.3 KiB
Plaintext
Raw Normal View History

2024-01-30 23:48:00 +08:00
<%
2024-02-03 14:38:34 +08:00
var banner_url
if (page.banner) {
banner_url = page.banner
} else if (theme.topic.tree[page.topic]?.banner != null) {
banner_url = theme.topic.tree[page.topic]?.banner
} else if (theme.wiki.tree[page.wiki]?.banner != null) {
banner_url = theme.wiki.tree[page.wiki]?.banner
}
2024-01-30 23:48:00 +08:00
function layoutTitle() {
const title = page.h1 != null ? page.h1 : page.title
if (title && title.length > 0) {
return `<h1 class="text title"><span>${title}</span></h1>`
} else {
return ''
}
}
function layoutBottom() {
const article_title = layoutTitle()
if (article_title.length > 0) {
return `
<div class="bottom">
<div class="text-area">
${article_title}
</div>
</div>
`
} else {
return ``
}
}
function layoutDiv() {
const top = partial('article_top_area')
const bottom = layoutBottom()
if (top.trim().length == 0 && bottom.length == 0) {
return ``
}
2024-01-31 13:58:56 +08:00
var style = ``
2024-01-30 23:48:00 +08:00
var el = ``
el += `<div class="article banner top">`
2024-02-03 14:38:34 +08:00
if (banner_url?.length > 0) {
2024-01-30 23:48:00 +08:00
el += `<img class="bg" src="${banner_url}">`
2024-01-31 13:58:56 +08:00
if (page.poster?.color) {
style += ' style="--text-banner:' + page.poster?.color + '"'
}
2024-01-30 23:48:00 +08:00
}
el += `
<div class="content"${style}>
${top}
${bottom}
</div>
`
el += `</div>`
return el
}
%>
<%- layoutDiv() %>