Skip to content

Commit

Permalink
feat: add custom setting post copyright info (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
XPoet committed Mar 6, 2024
1 parent 82aa999 commit 8e4e1e4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
30 changes: 16 additions & 14 deletions layout/_partial/post/post-copyright-info.ejs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<%
let licenseLang = ''
let license_lang = ''
if (config?.language === 'zh-CN') { license_lang = '.zh-hans' }
if (config?.language === 'zh-TW') { license_lang = '.zh-hant' }
let license_url = 'https://creativecommons.org/licenses/by-nc-sa/4.0/deed' + license_lang
if (config?.language === 'zh-CN') {
licenseLang = '.zh-hans'
}
if (config?.language === 'zh-TW') {
licenseLang = '.zh-hant'
}
const use_custom = theme?.post?.copyright_info !== true && theme?.post?.copyright_info?.custom_license && theme?.post?.copyright_info?.custom_link
if (use_custom) { license_url = theme?.post?.copyright_info?.custom_link }
%>
<div class="post-copyright-info-container border-box">
<div class="copyright-info-content border-box">
Expand Down Expand Up @@ -41,12 +39,16 @@ if (config?.language === 'zh-TW') {
<div class="type">
<%- __('copyright.license') %>
</div>
<div class="content tooltip" data-tooltip-content="CC BY-NC-SA 4.0">
<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed<%= licenseLang %>">
<i class="fa-brands fa-creative-commons"></i>
<i class="fa-brands fa-creative-commons-by"></i>
<i class="fa-brands fa-creative-commons-nc"></i>
<i class="fa-brands fa-creative-commons-sa"></i>
<div class="content tooltip" data-tooltip-content="<%= use_custom ? '' : 'CC BY-NC-SA 4.0' %>">
<a href="<%= license_url %>" target="_blank">
<% if (use_custom) { %>
<%= theme?.post?.copyright_info?.custom_license %>
<% } else { %>
<i class="fa-brands fa-creative-commons"></i>
<i class="fa-brands fa-creative-commons-by"></i>
<i class="fa-brands fa-creative-commons-nc"></i>
<i class="fa-brands fa-creative-commons-sa"></i>
<% } %>
</a>
</div>
</div>
Expand Down
7 changes: 5 additions & 2 deletions layout/post-content.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ const post_avatar = page?.avatar || theme?.base_info?.avatar
<%- page.content %>
</div>
<% if (
(theme?.post?.copyright_info === true || theme?.copyright_info?.enable === true) && page?.copyright_info !== false
(
theme?.post?.copyright_info === true
|| (theme?.post?.copyright_info?.custom_license && theme?.post?.copyright_info?.custom_link)
)
&& page?.copyright_info !== false
) { %>
<%- partial('_partial/post/post-copyright-info') %>
<% } %>
Expand Down

0 comments on commit 8e4e1e4

Please sign in to comment.