[opt] license author info

This commit is contained in:
xaoxuu 2024-01-08 12:38:50 +08:00
parent 54d47a8e64
commit 503b2fd16c
1 changed files with 16 additions and 5 deletions

View File

@ -40,25 +40,36 @@ function layoutDiv() {
var license = '' var license = ''
if (page.layout == 'post') { if (page.layout == 'post') {
if (theme.article.license && (page.license != false)) { if (theme.article.license && (page.license != false)) {
license = markdown(page.license || theme.article.license) license = page.license || theme.article.license
} }
} else if (page.layout == 'wiki' && page.wiki) { } else if (page.layout == 'wiki' && page.wiki) {
let proj = theme.wiki.tree[page.wiki] let proj = theme.wiki.tree[page.wiki]
if (page.license != null) { if (page.license != null) {
license = markdown(page.license || theme.article.license) license = page.license || theme.article.license
} else if (proj?.license != null) { } else if (proj?.license != null) {
if (proj.license == true) { if (proj.license == true) {
license = markdown(theme.article.license) license = theme.article.license
} else { } else {
license = markdown(proj.license) license = proj.license
} }
} }
} }
if (license.length > 0) { if (license.length > 0) {
var author = null
if (theme.authors) {
if (page.author?.length > 0 && theme.authors[page.author] != null) {
author = theme.authors[page.author]
} else {
author = theme.default_author
}
}
if (author) {
license = license.replace('${author.name}', author.name).replace('${author.url}', author.url)
}
el += ` el += `
<section id="license"> <section id="license">
<div class="header"><span>${__('meta.license')}</span></div> <div class="header"><span>${__('meta.license')}</span></div>
<div class="body">${license}</div> <div class="body">${markdown(license)}</div>
</section> </section>
` `
} }