hexo-theme-stellar/layout/page.ejs

72 lines
1.7 KiB
Plaintext
Raw Normal View History

2021-02-22 13:19:21 +08:00
<%
2024-01-19 01:05:44 +08:00
const { layout } = page
// 是否使用 Heti 布局插件
const isUsingHeti = theme.plugins.heti && theme.plugins.heti.enable
// 是否使用 TianliGPT 插件
const isUsingTianliGPT = theme.plugins.tianli_gpt.enable && ['all', page.layout].includes(theme.plugins.tianli_gpt.field)
// 默认的 menu_id
if (page.menu_id == null) {
if (page.wiki) {
page.menu_id = 'wiki'
} else {
page.menu_id = 'post'
}
}
// 默认的 title
if (page.title == null) {
if (page.wiki) {
page.title = __('btn.wiki')
}
}
2021-02-22 13:19:21 +08:00
function layoutTitle() {
2024-01-19 01:05:44 +08:00
const title = page.h1 != null ? page.h1 : page.title
2021-02-22 13:19:21 +08:00
if (title && title.length > 0) {
2024-01-19 01:05:44 +08:00
return `<h1 class="article-title"><span>${title}</span></h1>`
2021-02-22 13:19:21 +08:00
} else {
2024-01-19 01:05:44 +08:00
return ''
2021-02-22 13:19:21 +08:00
}
}
2024-01-19 01:05:44 +08:00
function articleClass() {
var str = `md-text content${scrollreveal(' ')}`
if (isUsingHeti) {
str += ' heti'
}
if (isUsingTianliGPT) {
str += ' '
}
return str
}
function layoutDiv() {
2024-01-19 01:05:44 +08:00
var el = ''
2024-01-14 16:42:20 +08:00
if (page.nav_tabs) {
2024-01-19 01:05:44 +08:00
el += partial('_partial/main/navbar/nav_tabs_blog')
}
if (page.h1 || page.title || (page.content && page.content.length > 0)) {
2024-01-19 01:05:44 +08:00
el += partial('_partial/main/navbar/breadcrumb')
}
2024-01-19 01:05:44 +08:00
el += `<article class="${articleClass()}">`
el += layoutTitle()
if (page.content && page.content.length > 0) {
2024-01-19 01:05:44 +08:00
el += page.content
}
if (layout === 'post') {
el += partial('_partial/main/article/article_footer')
}
el += `</article>`
if (layout === 'post' || page.wiki) {
el += partial('_partial/main/article/read_next')
}
if (layout === 'post') {
el += partial('_partial/main/article/related_posts')
}
2024-01-19 01:05:44 +08:00
el += partial('_partial/plugins/comments/layout')
return el
}
2021-02-22 13:19:21 +08:00
%>
<%- layoutDiv() %>