[opt] banner

This commit is contained in:
xaoxuu 2024-02-03 14:38:34 +08:00
parent 295da76840
commit a60b1cbfb7
2 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,13 @@
<%
var banner_url = page.banner || ''
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
}
function layoutTitle() {
const title = page.h1 != null ? page.h1 : page.title
@ -35,7 +42,7 @@ function layoutDiv() {
var style = ``
var el = ``
el += `<div class="article banner top">`
if (banner_url.length > 0) {
if (banner_url?.length > 0) {
el += `<img class="bg" src="${banner_url}">`
if (page.poster?.color) {
style += ' style="--text-banner:' + page.poster?.color + '"'

View File

@ -10,6 +10,10 @@ if (['post', 'page', 'wiki', null].includes(page.layout)) {
var article_type = theme.article.type
if (page.type?.length > 0) {
article_type = page.type
} else if (theme.topic.tree[page.topic]?.type != null) {
article_type = theme.topic.tree[page.topic]?.type
} else if (theme.wiki.tree[page.wiki]?.type != null) {
article_type = theme.wiki.tree[page.wiki]?.type
}
// 是否缩进
var indent = false