Skip to content

Commit

Permalink
refactor(footer): support fill in more record information (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
XPoet committed May 14, 2024
1 parent 2d6bfb6 commit c2c9232
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 251 deletions.
24 changes: 8 additions & 16 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,30 +309,22 @@ pjax:
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/footer.html
# ---------------------------------------------------------------------------------------
footer:
since: 2020 # The starting year of your website, Can be null
word_count: false # Option values: true | false

icp:
enable: false # Option values: true | false
record_code: # ICP record code of your website
url: https://beian.miit.gov.cn # Your ICP link url, Can be null
since: 2020 # The starting year of your website, Can be null
word_count: false # Option values: true | false

site_deploy:
enable: false # Option values: true | false
provider: github # Option values: github | vercel | netlify | cloudflare | gitee | aliyun | tencent_cloud | upyun
url: # Your deployment provider url, Can be null

# When the footer style is shields, you can customize the shields configuration
# See: https://shields.io
shields_style:
record:
enable: false # Option values: true | false
custom:
- link_url: # Your link url, Can be null
img_url: # Shields image url
list:
- code: # record code of your website
link: # record link of your website, Can be null
# e.g.
# - link_url: https://github.com/XPoet/hexo-theme-keep
# img_url: https://img.shields.io/badge/Hexo-Keep%20v3.7.3-blue?style=flat-square&logo=hexo
# - ...
# - code: ICP 001
# - link: https://beian.miit.gov.cn


# ---------------------------------------------------------------------------------------
Expand Down
162 changes: 56 additions & 106 deletions layout/_partial/footer.ejs
Original file line number Diff line number Diff line change
@@ -1,136 +1,86 @@
<%
const {
since: f_since,
icp: f_icp,
record: f_record,
site_deploy: f_site_deploy
} = theme?.footer || {}
const { author: bi_author } = theme?.base_info || {}
const { author: hexo_author } = config
const { site_uv: bsz_site_uv, site_pv: bsz_site_pv, enable: bsz_enable } = theme?.website_count?.busuanzi_count || {}
const footer_style_type = theme.footer?.shields_style?.enable === true ? 'shields' : 'default'
const shields_style = 'flat-square'
const shields_color_list = ['dodgerblue', 'dodgerblue', 'dodgerblue', 'dodgerblue', 'dodgerblue', 'dodgerblue']
const web_master = bi_author || hexo_author
%>
<footer class="footer border-box">
<div class="border-box website-info-box <%= footer_style_type %>">
<% if (footer_style_type === 'shields') { %>
<div class="info-item">
<% const since_date = f_since ? f_since + '_--_' + date(new Date(), 'YYYY') : date(new Date(), 'YYYY') %>
<a class="shields-item">
<img src="https://img.shields.io/badge/Since-<%= since_date %>-<%= shields_color_list[0] %>?style=<%= shields_style %>">
</a>
<% if (web_master) { %>
<a class="shields-item" href="<%- url_for('/') %>">
<img src="https://img.shields.io/badge/WebMaster-<%= web_master %>-<%= shields_color_list[1] %>?style=<%= shields_style %>">
</a>
<% } %>
<% if (f_icp?.enable === true && f_icp?.record_code) { %>
<a class="shields-item<%= f_icp?.url ? '' : ' no-pointer' %>"
target="_blank"
href="<%= f_icp?.url %>"
>
<img src="https://img.shields.io/badge/ICP-<%= f_icp?.record_code %>-<%= shields_color_list[2] %>?style=<%= shields_style %>">
</a>
<% } %>
<a class="shields-item" href="https://hexo.io" target="_blank">
<img src="https://img.shields.io/badge/Powered_by-Hexo-<%= shields_color_list[3] %>?style=<%= shields_style %>">
</a>
<a class="shields-item" href="https://github.com/XPoet/hexo-theme-keep" target="_blank">
<img class="shields-keep-version" src="https://img.shields.io/badge/Theme-Keep-<%= shields_color_list[4] %>?style=<%= shields_style %>">
</a>
<% if (f_site_deploy?.enable === true && f_site_deploy?.provider) { %>
<a class="shields-item<%= f_site_deploy?.url ? '' : ' no-pointer' %>"
target="_blank"
rel="nofollow"
href="<%= f_site_deploy?.url %>"
>
<img src="https://img.shields.io/badge/Deploy_in-<%= __('footer.deploy_provider.' + f_site_deploy?.provider) %>-<%= shields_color_list[5] %>?style=<%= shields_style %>">
</a>
<% } %>
</div>
<% if (theme.footer?.shields_style?.enable === true) { %>
<div class="info-item">
<% theme.footer?.shields_style?.custom?.forEach((item) => { %>
<% if (item.img_url) { %>
<a class="shields-item<%= item.link_url ? '' : ' no-pointer' %>"
href="<%= item.link_url %>"
target="_blank"
>
<img src="<%- url_for(item.img_url) %>">
</a>
<% } %>
<% }) %>
</div>
<% } %>
<% } else { %>
<div class="copyright-info info-item <%= footer_style_type %>">
&copy;&nbsp;<% if (f_since) { %><span><%= f_since %></span>&nbsp;-&nbsp;<% } %><%= date(new Date(), 'YYYY') %>
<% if (web_master) { %>
&nbsp;<i class="fas fa-heart icon-animate"></i>&nbsp;&nbsp;<a href="<%- url_for('/') %>"><%= web_master %></a>
<% } %>
</div>
<div class="copyright-info info-item">
&copy;&nbsp;<% if (f_since) { %><span><%= f_since %></span>&nbsp;-&nbsp;<% } %><%= date(new Date(), 'YYYY') %>
<% if (web_master) { %>
&nbsp;<i class="fas fa-heart icon-animate"></i>&nbsp;&nbsp;<a href="<%- url_for('/') %>"><%= web_master %></a>
<% } %>
</div>
<div class="theme-info info-item <%= footer_style_type %>">
<%- __('footer.powered_by', '<a target="_blank" href="https://hexo.io">Hexo</a>') %>&nbsp;&&nbsp;<%- __('theme') %>&nbsp;<a class="keep-version" target="_blank" href="https://github.com/XPoet/hexo-theme-keep">Keep</a>
</div>
<div class="theme-info info-item">
<%- __('footer.powered_by', '<a target="_blank" href="https://hexo.io">Hexo</a>') %>&nbsp;&&nbsp;<%- __('theme') %>&nbsp;<a class="keep-version" target="_blank" href="https://github.com/XPoet/hexo-theme-keep">Keep</a>
</div>
<% if (f_icp?.enable && f_icp?.record_code) { %>
<div class="icp-info info-item <%= footer_style_type %>">
<a class="<%= f_icp?.url ? '' : ' no-pointer' %>"
target="_blank"
href="<%= f_icp?.url %>"
>
<%= f_icp?.record_code %>
</a>
</div>
<% if (f_site_deploy?.enable === true && f_site_deploy?.provider) { %>
<% const deploy_provider_img_tag = image_tag('/images/brands/' + f_site_deploy?.provider + '.png') %>
<div class="deploy-info info-item">
<% if (f_site_deploy?.url) { %>
<a target="_blank" rel="nofollow" href="<%= f_site_deploy?.url %>">
<% } %>
<% if (f_site_deploy?.enable === true && f_site_deploy?.provider) { %>
<% const deploy_provider_img_tag = image_tag('/images/brands/' + f_site_deploy?.provider + '.png') %>
<div class="deploy-info info-item <%= footer_style_type %>">
<% if (f_site_deploy?.url) { %>
<a target="_blank" rel="nofollow" href="<%= f_site_deploy?.url %>">
<% } %>
<%- __(
'footer.deploy',
'<span class="tooltip" data-tooltip-content="' + __('footer.deploy_provider.' + f_site_deploy?.provider) + '">' + deploy_provider_img_tag + '</span>'
) %>
<% if (f_site_deploy?.url) { %>
</a>
<% } %>
</div>
<%- __(
'footer.deploy',
'<span class="tooltip" data-tooltip-content="' + __('footer.deploy_provider.' + f_site_deploy?.provider) + '">' + deploy_provider_img_tag + '</span>'
) %>
<% if (f_site_deploy?.url) { %>
</a>
<% } %>
<% } %>
</div>
<% } %>
<div class="count-item info-item <%= footer_style_type %>">
<%
let f_temp_total_word;
try {
f_temp_total_word = totalcount(site);
} catch (e) {
f_temp_total_word = 0;
}
if (theme.footer?.word_count === true && f_temp_total_word !== 0) { %>
<span class="count-box border-box word">
<div class="count-info info-item">
<%
let f_temp_total_word;
try {
f_temp_total_word = totalcount(site);
} catch (e) {
f_temp_total_word = 0;
}
if (theme.footer?.word_count === true && f_temp_total_word !== 0) { %>
<span class="count-item border-box word">
<span class="item-type border-box"><%- __('footer.total_words') %></span>
<span class="item-value border-box word"><%= totalcount(site) %></span>
</span>
<% } %>
<% } %>
<% if (bsz_enable === true && bsz_site_uv === true) { %>
<span class="count-box border-box uv">
<% if (bsz_enable === true && bsz_site_uv === true) { %>
<span class="count-item border-box uv">
<span class="item-type border-box"><%- __('footer.site_uv') %></span>
<span class="item-value border-box uv" id="busuanzi_value_site_uv"></span>
</span>
<% } %>
<% } %>
<% if (bsz_enable === true && bsz_site_pv === true) { %>
<span class="count-box border-box pv">
<% if (bsz_enable === true && bsz_site_pv === true) { %>
<span class="count-item border-box pv">
<span class="item-type border-box"><%- __('footer.site_pv') %></span>
<span class="item-value border-box pv" id="busuanzi_value_site_pv"></span>
</span>
<% } %>
</div>
<% if (f_record?.enable === true) { %>
<div class="record-info info-item">
<% for (let i = 0; i < f_record?.list?.length; i++) { %>
<% if (f_record?.list[i]?.code) { %>
<div class="record-item border-box">
<a class="<%= f_record?.list[i]?.link ? '' : ' no-pointer' %>"
target="_blank"
href="<%= f_record?.list[i]?.link %>"
>
<%= f_record?.list[i].code %>
</a>
</div>
<% } %>
<% } %>
</div>
</div>
<% } %>
</footer>
Loading

0 comments on commit c2c9232

Please sign in to comment.