Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于旧版本的插件 needmoreshare2 #667

Closed
3 tasks done
ThisisXXZ opened this issue Jun 13, 2023 · 4 comments
Closed
3 tasks done

关于旧版本的插件 needmoreshare2 #667

ThisisXXZ opened this issue Jun 13, 2023 · 4 comments
Labels
Feature Request New feature or request Solved

Comments

@ThisisXXZ
Copy link

Issue Checklist

Expected behavior

我最近正在将 NexT 版本由 7.8.0 更新到最新的版本。在更新时我发现之前使用的 needmoreshare2 插件会产生显示错误。本来应该位于 bottomCenter 的 share 按钮移到了 bottomLeft。
可能是和新版本的 NexT 版本不适配,但是我真的很喜欢这个插件,比现在这个版本集成的 AddToAny share 好看的多。请问可以将这个插件集成到新版本中,或者告诉我解决的办法吗?
谢谢!
旧版本的 needmoreshare 在这里
这是在主题配置文件 config.yml 中关于 needmoreshare 的配置

# NeedMoreShare2
# Dependencies: https://github.com/theme-next/theme-next-needmoreshare2
# For more information: https://github.com/revir/need-more-share2
# iconStyle: default | box
# boxForm: horizontal | vertical
# position: top / middle / bottom + Left / Center / Right
# networks:
# Weibo | Wechat | Douban | QQZone | Twitter | Facebook | Linkedin | Mailto | Reddit | Delicious | StumbleUpon | Pinterest
# GooglePlus | Tumblr | GoogleBookmarks | Newsvine | Evernote | Friendfeed | Vkontakte | Odnoklassniki | Mailru
needmoreshare:
  enable: true
  cdn:
    js: //cdn.jsdelivr.net/gh/theme-next/theme-next-needmoreshare2@1/needsharebutton.min.js
    css: //cdn.jsdelivr.net/gh/theme-next/theme-next-needmoreshare2@1/needsharebutton.min.css
  postbottom:
    enable: true
    options:
      iconStyle: box
      boxForm: horizontal
      position: bottomCenter
      networks: Wechat,QQZone,Weibo,Douban,Twitter,Facebook
  float:
    enable: false
    options:
      iconStyle: box
      boxForm: horizontal
      position: middleRight
      networks: Wechat,QQZone,Weibo,Douban,Twitter,Facebook

预期的效果 (在旧版本中正确显示)
image

Actual behavior

  • Links to demo site with this issue:
  • Links to repository or source code of the blog:
  • Screenshots:
    image
    分享按钮出现在了屏幕左侧

Steps to reproduce the behavior

根据上文即可

Other Information

No response

@ThisisXXZ ThisisXXZ added the Feature Request New feature or request label Jun 13, 2023
@welcome
Copy link

welcome bot commented Jun 13, 2023

Thanks for opening this issue, maintainers will get back to you as soon as possible!

@ThisisXXZ
Copy link
Author

UPD. 尝试在 CSS 源码中添加一行 margin-left: 50%; ,按钮位置显示正常,但是弹出来的分享窗口又出现了偏移

image

@ThisisXXZ
Copy link
Author

再附上 needmoreshare.js 的源码以供参考

module.exports = function(config, injects) {
  injects.head.raw('needmoreshare', `<link rel="stylesheet" href="${config.cdn.css}">`);
  if (config.postbottom.enable) {
    injects.head.raw('needmoreshare-postbottom', `<style>
#needsharebutton-postbottom {
  cursor: pointer;
  height: 26px;
  margin-top: 10px;
  margin-left: 50%;
  position: relative;
}
#needsharebutton-postbottom .btn {
  border: 1px solid $btn-default-border-color;
  border-radius: 3px;
  display: initial;
  padding: 1px 4px;
}
</style>`);
    injects.postBodyEnd.raw('needmoreshare-postbottom', `<div class="post-widgets">
      <div id="needsharebutton-postbottom">
        <span class="btn">
          <i class="fa fa-share-alt" aria-hidden="true"></i>
        </span>
      </div>
    </div>`);
  }
  if (config.float.enable) {
    injects.head.raw('needmoreshare-float', `<style>
#needsharebutton-float {
  bottom: 88px;
  cursor: pointer;
  left: -8px;
  position: fixed;
  z-index: 9999;
}
#needsharebutton-float .btn {
  border: 1px solid $btn-default-border-color;
  border-radius: 4px;
  padding: 0 10px 0 14px;
}
</style>`);
    injects.bodyEnd.raw('needmoreshare-float', `<div id="needsharebutton-float">
      <span class="btn">
        <i class="fa fa-share-alt" aria-hidden="true"></i>
      </span>
    </div>`);
  }
  injects.bodyEnd.raw('needmoreshare', `
  <script src="${config.cdn.js}"></script>
  <script>
    {%- if config.needmoreshare.postbottom.enable %}
      pbOptions = {};
      {%- for k,v in config.needmoreshare.postbottom.options %}
        pbOptions.{{ k }} = "{{ v }}";
      {%- endfor %}
      new needShareButton('#needsharebutton-postbottom', pbOptions);
    {%- endif %}
    {%- if config.needmoreshare.float.enable %}
      flOptions = {};
      {%- for k,v in config.needmoreshare.float.options %}
        flOptions.{{ k }} = "{{ v }}";
      {%- endfor %}
      new needShareButton('#needsharebutton-float', flOptions);
    {%- endif %}
  </script>`);
};

@stevenjoezhang
Copy link
Member

需要单独加CSS:

.post-widgets {
  border-top: 1px solid $gainsboro;
  margin-top: 15px;
  text-align: center;
}

179176e

原版的 need-more-share2 已经很久没更新了: https://github.com/revir/need-more-share2 未来可能不会再适配了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request New feature or request Solved
Projects
None yet
Development

No branches or pull requests

2 participants