liuyib/hexo-theme-stun

增加公安备案选项

Closed this issue · 1 comments

I want to create a new issue

Stun Information

Stun Version: v2.1.1

Hexo Version: v4.2.1

Platform: Windows

Browser: Chrome

Expected behaviour

Actual behaviour

Steps to reproduce the behaviour

Feature Request

由于主题未提供公安备案设置项,我自己修改了一下footer.pug,以下是修改后的内容:

-
  var footer = theme.footer;
  var nowYear = new Date().getFullYear();
  var startYear = footer.copyright.since || nowYear;
  var endYear = footer.copyright.end || nowYear;
  var footerCopyright = footer.copyright.enable
if footerCopyright
  div
    if footerCopyright
      span= `Copyright © ${startYear}` + ((startYear !== endYear) ? `~${endYear}` : '')
      if footer.icon.enable
        span(class="footer__icon")
          i(class=footer.icon.name)
      else
        span.footer__devider
      span!= footer.copyright.text || config.author

-
  var footerBeianicp = footer.beianicp.enable
  var footerBeiangongan = footer.beiangongan.enable
if footerBeianicp || footerBeiangongan
  div
    if footerBeianicp
      span
        != _p(link_to('http://www.beian.miit.gov.cn', footer.beianicp.icp, { external: true }))
    if footerBeianicp && footerBeiangongan
      span.footer__devider= '|'
    if footerBeiangongan
      span
        != _p(link_to(footer.beiangongan.gongan_url, footer.beiangongan.gongan_id, { external: true }))

-
  var footerPowered = footer.powered.enable
  var footerTheme = footer.theme.enable
if footerPowered || footerTheme
  div
    if footerPowered
      span
        != _p('footer.powered', link_to(HEXO_URL, 'Hexo', { external: true }))
      if footer.powered.version
        span= ' v' + hexo_env('version')
    if footerPowered && footerTheme
      span.footer__devider= '|'
    if footerTheme
      span= __('footer.theme') + ' - '
        != link_to(STUN_URL, 'Stun', { external: true })
      if footer.theme.version
        span= ' v' + stun_env('version')

if theme.busuanzi.enable
  include ../analytics/busuanzi.pug

if footer.custom.enable
  div!= footer.custom.text

由于对pug不熟悉,中间加入的代码是根据上下文推测写出的,不知道格式有没有问题。

另外有个问题想请教一下,想要在公安备案(footerBeiangongan)的前面插入一个图片,上面这段代码应该怎么改一下?


@Hades-001 你添加的代码中

!= _p(link_to('http://www.beian.miit.gov.cn', footer.beianicp.icp, { external: true }))
!= _p(link_to(footer.beiangongan.gongan_url, footer.beiangongan.gongan_id, { external: true }))

这两句不对,把 _p() 去掉就可以了。
另外,插入图片,直接写个 img 标签就行:img(src="xxx" alt="xxx")

虽然 Stun 主题未提供公安备案设置项,但是配置中的 footer.custom.text 是允许设置为 html 的,所以可以在这个配置项中,实现任何 HTML + CSS 代码效果,亦可实现插入“公安备案” 相关信息。
关于添加公安备案,这个主题后面会实现,并提供配置项,感谢反馈 ❤️。